diff --git a/app.config.environment.dev.js b/app.config.environment.dev.js new file mode 100644 index 0000000000000000000000000000000000000000..14d6a3ca2d7e62b290d3234b7695e35998c89cf0 --- /dev/null +++ b/app.config.environment.dev.js @@ -0,0 +1,54 @@ +'use strict' + +const webpack = require('webpack') +const merge = require('webpack-merge') +const { useHotReload, devtool } = require('./webpack.vars') + +let plugins = [ + new webpack.DefinePlugin({ + __DEVELOPMENT__: true, + }), +] + +// In development, the bar and cozy-client-js are provided automatically. We use the ProvidePlugin +// since it allows us to use in production the cozy.bar and cozy.client declared by the <script /> +// line injected by the stack, while in developement to have it "served" from +// our node_modules +const stackProvidedLibsConfig = { + plugins: [ + new webpack.DefinePlugin({ + __STACK_ASSETS__: true, + }), + ], + module: { + rules: [ + { + test: /cozy-bar\/dist\/cozy-bar\.min\.js$/, + // Automatically import the CSS if the JS is imported. + // imports-loader@0.8.0 works but imports-loader@1.0.0 does not + loader: 'imports-loader?css=./cozy-bar.min.css', + }, + ], + }, +} + +const output = {} +if (useHotReload) { + plugins = plugins.concat([new webpack.HotModuleReplacementPlugin()]) + output.globalObject = 'this' +} + +module.exports = merge( + { + devtool: devtool || 'cheap-module-eval-source-map', + mode: 'development', + externals: ['cozy'], + plugins, + output, + optimization: { + removeAvailableModules: false, + removeEmptyChunks: false, + }, + }, + stackProvidedLibsConfig +) diff --git a/app.config.js b/app.config.js index 21d137b224ff8a6abcce6759d71ff6716667402e..441171d42eb34c5c72e4b582ac533ce71f8ee43e 100644 --- a/app.config.js +++ b/app.config.js @@ -33,9 +33,9 @@ const configs = [ ] if (environment === 'production') { - configs.push(require('cozy-scripts/config/webpack.environment.prod')) + configs.push(require('./app.config.environment.dev')) } else { - configs.push(require('cozy-scripts/config/webpack.environment.dev')) + configs.push(require('cozy-scripts/config/webpack.environment.prod')) } //module.exports = merge.apply(null, configs)