Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exclude: /node_modules/
}),
env('development', [
devServer([
`webpack-dev-server/client?http://localhost:${WEBPACK_DEV_PORT}`,
'webpack/hot/only-dev-server'
]),
devServer.proxy({
'*': { target: `http://localhost:${DEV_PORT}` }
}),
devServer.reactHot({
exclude: /node_modules/
}),
sourceMaps()
]),
env('production', [
addPlugins([
// Try to dedupe duplicated modules, if any:
new webpack.optimize.DedupePlugin(),
// Minify the code.
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true, // React doesn't support IE8
warnings: false
},
mangle: {
screw_ie8: true
},
output: {
comments: false,
screw_ie8: true
}
}),
cssLoader(),
addPlugins([
// This helps ensure the builds are consistent if source hasn't changed:
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(ENV)
}
}),
new ManifestPlugin()
]),
babel({
exclude: /node_modules/
}),
env('development', [
devServer([
`webpack-dev-server/client?http://localhost:${WEBPACK_DEV_PORT}`,
'webpack/hot/only-dev-server'
]),
devServer.proxy({
'*': { target: `http://localhost:${DEV_PORT}` }
}),
devServer.reactHot({
exclude: /node_modules/
}),
sourceMaps()
]),
env('production', [
addPlugins([
// Try to dedupe duplicated modules, if any:
new webpack.optimize.DedupePlugin(),
compress: {
warnings: false
}
}
}),
addPlugins([
new CleanWebpackPlugin([appPath('build')], {
root: process.cwd()
}),
new CopyWebpackPlugin([{ from: 'public', to: '' }])
])
])
]),
userConfig,
createConfig([
env('test', [
customConfig({
target: 'node',
externals: [nodeExternals()],
output: {
// use absolute paths in sourcemaps (important for debugging via IDE)
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
devtoolFallbackModuleFilenameTemplate:
'[absolute-resource-path]?[hash]'
},
module: {
rules: [
{
test: /\.(jsx?|tsx?)/,
include: packageJson.nyc.include.map(p =>
path.resolve(appPath(p))
),
name = 'vendor',
test = /\.js$/,
exclude,
} = typeof options === 'object' ? options : ({ name: options }: Options)
return group([
setOutput({
filename: '[name].js',
}),
addPlugins([
new webpack.optimize.CommonsChunkPlugin({
name,
minChunks: ({ resource }) => isVendor(resource, test, exclude),
}),
]),
env('production', [
setOutput({
filename: '[name].[chunkhash].js',
}),
addPlugins([
new WebpackMd5Hash(),
]),
]),
])
}
new HtmlWebpackHarddiskPlugin({
outputPath: appPath('public')
}),
new webpack.ProvidePlugin({
Snabbdom: 'snabbdom-pragma'
})
]),
env('development', [
devServer({
port: PORT,
contentBase: appPath('public')
}),
sourceMaps(),
addPlugins([new webpack.NamedModulesPlugin()])
]),
env('production', [
uglify({
parallel: true,
cache: true,
uglifyOptions: {
compress: {
warnings: false
}
}
}),
addPlugins([
new CleanWebpackPlugin([appPath('build')], {
root: process.cwd()
}),
new CopyWebpackPlugin([{ from: 'public', to: '' }])
])
])
addPlugins([
new HtmlWebpackPlugin({
template: './index.ejs',
alwaysWriteToDisk: true,
inject: true,
favicon: 'public/favicon.png',
hash: true
}),
new HtmlWebpackHarddiskPlugin({
outputPath: appPath('public')
}),
new webpack.ProvidePlugin({
Snabbdom: 'snabbdom-pragma'
})
]),
env('development', [
devServer({
port: PORT,
contentBase: appPath('public')
}),
sourceMaps(),
addPlugins([new webpack.NamedModulesPlugin()])
]),
env('production', [
uglify({
parallel: true,
cache: true,
uglifyOptions: {
compress: {
warnings: false
}
}