tweak webpack config to make it faster and more correct

This commit is contained in:
Nolan Lawson 2018-03-24 18:17:55 -07:00
parent 6fc21e40bf
commit 143d80c94e

View file

@ -9,7 +9,7 @@ module.exports = {
entry: config.client.entry(), entry: config.client.entry(),
output: config.client.output(), output: config.client.output(),
resolve: { resolve: {
extensions: ['.js', '.html'] extensions: ['.js', '.json', '.html']
}, },
mode: isDev ? 'development' : 'production', mode: isDev ? 'development' : 'production',
module: { module: {
@ -36,11 +36,6 @@ module.exports = {
}, },
!isDev && { !isDev && {
test: /\.css$/, test: /\.css$/,
/* disable while https://github.com/sveltejs/sapper/issues/79 is open */
/* use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{ loader: 'css-loader', options: { sourceMap:isDev } }]
}) */
use: [ use: [
{ loader: 'style-loader' }, { loader: 'style-loader' },
{ loader: 'css-loader' } { loader: 'css-loader' }
@ -51,19 +46,18 @@ module.exports = {
node: { node: {
setImmediate: false setImmediate: false
}, },
plugins: isDev ? [ plugins: [
new LodashModuleReplacementPlugin({
collections: true,
caching: true
})
].concat(isDev ? [
new webpack.HotModuleReplacementPlugin() new webpack.HotModuleReplacementPlugin()
] : [ ] : [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.browser': true, 'process.browser': true,
'process.env.NODE_ENV': '"production"' 'process.env.NODE_ENV': '"production"'
}), }),
/* disable while https://github.com/sveltejs/sapper/issues/79 is open */
// new ExtractTextPlugin('main.css'),
new LodashModuleReplacementPlugin({
collections: true,
caching: true
}),
new BundleAnalyzerPlugin({ // generates report.html and stats.json new BundleAnalyzerPlugin({ // generates report.html and stats.json
analyzerMode: 'static', analyzerMode: 'static',
generateStatsFile: true, generateStatsFile: true,
@ -74,6 +68,6 @@ module.exports = {
openAnalyzer: false, openAnalyzer: false,
logLevel: 'silent' // do not bother Webpacker, who runs with --json and parses stdout logLevel: 'silent' // do not bother Webpacker, who runs with --json and parses stdout
}) })
], ]),
devtool: isDev ? 'cheap-module-source-map' : 'source-map' devtool: isDev ? 'cheap-module-eval-source-map' : 'source-map'
} }