Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
config.plugins.push(new HtmlWebpackPlugin({
template: './src/modules/app/index.html',
inject: 'body',
minify: options.BUILD,
hash: true
}));
}
if (options.BUILD) {
config.plugins.push(new HtmlWebpackPlugin({
template: './src/modules/app/index.html',
inject: 'body',
minify: options.BUILD,
hash: true
}));
config.plugins.push(new webpack.NoErrorsPlugin(),
// Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
// Minify all javascript, switch loaders to minimizing mode
new ClosureCompilerPlugin(),
new webpack.optimize.UglifyJsPlugin({
output: {comments: false}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(true),
new CompressionPlugin({
asset: "{file}.gz",
algorithm: "gzip",
regExp: /\.js$|\.html$/,
threshold: 10240,
minRatio: 0.8
}));
}
extensions: ['', '.js', '.json'],
alias: {
'react': './pages/build/react'
},
modulesDirectories: ['node_modules', 'assets/libraries', 'assets/styles', 'assets/images']
}
}
if (isProd) {
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
)
} else {
config.devtool = 'source-map'
config.devServer = {
contentBase: PATHS.build,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
loaders: ['babel?cacheDirectory', 'eslint']
}, {
test: /\.css$/,
loaders: [
'style-loader',
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
]
}, {
test: /\.scss$/,
loader: 'style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!sass?outputStyle=expanded&sourceMap'
});
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'__DEV__': true,
'process.env': {
'NODE_ENV': JSON.stringify('development')
}
})
);
config.target = webpackTargetElectronRenderer(config);
module.exports = config;
]
}
if (options.loaders)
loaders = loaders.concat(options.loaders)
if (options.minimize)
plugins.push(
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'__VERSION__': JSON.stringify(pkg.version),
"process.env": { NODE_ENV: JSON.stringify("production") }
}),
new webpack.NoErrorsPlugin())
else
plugins.push(
new webpack.DefinePlugin({
'__VERSION__': JSON.stringify(pkg.version)
}));
if (options.extractStyles)
plugins.push(
new ExtractTextPlugin(options.styleName || "styles.css", {
allChunks: true
}))
if (options.banner) {
plugins.push(
new webpack.BannerPlugin(
'v' + JSON.stringify(pkg.version) + ' | (c) ' + (new Date).getFullYear() + ' Jason Quense | '
module.exports = (app, opt) => {
clientConfig.entry.app = ['webpack-hot-middleware/client', clientConfig.entry.app]
clientConfig.output.filename = '[name].js'
clientConfig.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
)
const clientCompiler = webpack(clientConfig)
const devMiddleware = webpackDevMiddleware(clientCompiler, {
publicPath: clientConfig.output.publicPath,
stats: {
colors: true,
chunks: false
}
})
app.use(devMiddleware)
clientCompiler.plugin('done', () => {
const fs = devMiddleware.fileSystem
const filePath = path.join(clientConfig.output.path, 'index.html')
warnings: false
},
output: {
comments: false
},
sourceMap: false
}));
plugins.push(new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}));
break;
case 'development':
case 'test':
plugins.push(new webpack.HotModuleReplacementPlugin());
plugins.push(new webpack.NoErrorsPlugin());
break;
default:
break;
}
module.exports = {
debug: nodeDebug,
devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
noInfo: nodeEnv === 'test',
entry: {
bundle: srcPath,
vendor: ['react', 'react-dom', 'redux', 'redux-thunk', 'react-redux', 'react-router', 'react-router-redux', 'classnames'].concat(isDev ? ['webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000', 'react-hot-loader/patch?quiet=false'] : [])
},
output: {
path: path.join(__dirname, isProd ? 'build' : '.tmp'),
pathinfo: true,
if(env === 'production') {
if(rev) {
webpackConfig.plugins.push(new webpackManifest(publicPath, config.root.dest))
}
webpackConfig.plugins.push(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
output: { comments: false },
compress: { drop_console: true },
}),
new webpack.NoErrorsPlugin()
)
}
return webpackConfig
}
template: paths.client('index.html'),
hash: false,
favicon: paths.client('static/favicon.ico'),
filename: 'index.html',
inject: 'body',
minify: {
collapseWhitespace: true
}
})
]
if (__DEV__) {
debug('Enable plugins for live development (HMR, NoErrors).')
webpackConfig.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
)
} else if (__PROD__) {
debug('Enable plugins for production (OccurenceOrder, Dedupe & UglifyJS).')
webpackConfig.plugins.push(
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false
}
})
)
}
loaders: [
{ test: /\.jsx$/, exclude: /node_modules/, loaders: ['react-hot', 'babel?stage=1'] },
{ test: /\.js$/, exclude: /node_modules/, loaders: ['react-hot', 'babel?stage=1'] },
{ test: /\.json$/, include: /\.json$/, loaders: ['json-loader'] }
]
},
resolve: { extensions: ['', '.js', '.jsx'] },
plugins: []
};
enableEslint(config);
enableVendor(config, productionMode);
config.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
enableCssModules(config);
enableHotReload(config, productionMode);
config.plugins.push(new webpack.NoErrorsPlugin());
return config;
}
config.entry[prop] = [hot].concat(config.entry[prop])
}
config.module.loaders.forEach(loader => {
if (loader.query) {
loader.query.presets.push('react-hmre')
}
})
config.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"development"'
}),
new webpack.NoErrorsPlugin()
]
config.devtool = 'source-map'
delete config.externals
let compiler = webpack(config)
return combineMiddleware([
webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }),
webpackHotMiddleware(compiler)
])
}