From 6d8dbbcbf4f858470d492e067512ae452f57dbe3 Mon Sep 17 00:00:00 2001 From: Vikas <v1k45x@gmail.com> Date: Thu, 27 May 2021 15:26:04 +0530 Subject: [PATCH] Add webpack static-dev config to use React app without webpack server --- gulpfile.js | 3 ++- .../src/app/webpack.static.dev.config.js | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 hypha/static_src/src/app/webpack.static.dev.config.js diff --git a/gulpfile.js b/gulpfile.js index bc3e3afe9..6dc5fe4c9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -73,6 +73,7 @@ sass.compiler = require('sass'); // Load webpack config var webpackDev = () => require(options.theme.app + 'webpack.dev.config.js'); +var webpackStaticDev = () => require(options.theme.app + 'webpack.static.dev.config.js'); var webpackProd = () => require(options.theme.app + 'webpack.prod.config.js'); var webpackAnalyze = () => require(options.theme.app + 'webpack.analyze.config.js'); @@ -178,7 +179,7 @@ gulp.task('scripts:production', gulp.series('clean:js', function js () { // Build App. gulp.task('app', function() { return gulp.src(options.theme.app + 'src/') - .pipe(webpackStrm( webpackDev() )) + .pipe(webpackStrm( webpackStaticDev() )) .pipe(gulp.dest(options.theme.app_dest)); }) diff --git a/hypha/static_src/src/app/webpack.static.dev.config.js b/hypha/static_src/src/app/webpack.static.dev.config.js new file mode 100644 index 000000000..f70897a75 --- /dev/null +++ b/hypha/static_src/src/app/webpack.static.dev.config.js @@ -0,0 +1,25 @@ +var webpack = require('webpack') +var BundleTracker = require('webpack-bundle-tracker') + +var config = require('./webpack.base.config.js') + +staticDevConfig = config('production') + +staticDevConfig.output.path = require('path').resolve('./assets/dist') + +staticDevConfig.plugins = staticDevConfig.plugins.concat([ + new BundleTracker({ filename: './hypha/static_compiled/app/webpack-stats.json' }), + new webpack.EnvironmentPlugin({ + NODE_ENV: 'production', + API_BASE_URL: null , + }), +]) + +staticDevConfig.optimization = {} + + +/** + * A webpack config similar to production, but produces development-oriented webpack-stats file. + * This makes it possible to use React application without Webpack Dev Server. + */ +module.exports = staticDevConfig -- GitLab