merge.smart(baseConfig, { mode: "development", plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') }) ], devServer: { contentBase: path.resolve(__dirname, 'build'), port: 3071, before() { spawn( 'electron', ['app/main-dev.js'], { shell: true, env: process.env, stdio: 'inherit' } ) .on('close', code => process.exit(0)) .on('error', spawnError => console.error(spawnError)) } } })
PROJECTS.map(project => { const additionalProjectConfig = require(additionalConfigPath)(project); commonConfig.plugins.push( new webpack.DefinePlugin({ 'process.env': { NODE_ENV: `'${process.env.NODE_ENV}'`, }, __PROJECT__: project, __DEVELOPMENT__: process.env.NODE_ENV === 'development', __TEST__: process.env.NODE_ENV === 'test', __PRODUCTION__: process.env.NODE_ENV === 'production', __CLIENT__: true, }) ); if (process.env.NODE_ENV === 'development') { resultConfig = merge.smart( additionalProjectConfig, !R.isEmpty(resultConfig) ? resultConfig : commonConfig ); } else { resultConfig.push(merge(additionalProjectConfig, commonConfig)); } });
/** * Creates the webpack config * @param {Gasket} gasket The Gasket API * @param {Object} webpackConfig Initial webpack config * @param {Object} data Additional info * @returns {Object} Final webpack config */ function initWebpack(gasket, webpackConfig, data) { const { execSync, config } = gasket; const chain = new WebpackChain(); execSync('webpackChain', chain, data); // // Merge defaults with gasket.config webpack. // webpackConfig = webpackMerge.smart( webpackConfig, { plugins: [new WebpackMetricsPlugin({ gasket })] }, webpackDefaults, // Defaults above chain.toConfig(), // Webpack chain from plugins (partial) config.webpack || {} // Webpack config from user (partial) ); const configs = execSync('webpack', webpackConfig, data).filter(Boolean); return webpackMerge.smart(webpackConfig, ...configs); }
/** * Creates the webpack config * @param {Gasket} gasket The Gasket API * @param {Object} webpackConfig Initial webpack config * @param {Object} data Additional info * @returns {Object} Final webpack config */ function initWebpack(gasket, webpackConfig, data) { const { execSync, config } = gasket; const chain = new WebpackChain(); execSync('webpackChain', chain, data); // // Merge defaults with gasket.config webpack. // webpackConfig = webpackMerge.smart( webpackConfig, { plugins: [new WebpackMetricsPlugin({ gasket })] }, webpackDefaults, // Defaults above chain.toConfig(), // Webpack chain from plugins (partial) config.webpack || {} // Webpack config from user (partial) ); const configs = execSync('webpack', webpackConfig, data).filter(Boolean); return webpackMerge.smart(webpackConfig, ...configs); }