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(),
output: config.client.output(),
resolve: {
extensions: ['.js', '.html']
extensions: ['.js', '.json', '.html']
},
mode: isDev ? 'development' : 'production',
module: {
@ -36,11 +36,6 @@ module.exports = {
},
!isDev && {
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: [
{ loader: 'style-loader' },
{ loader: 'css-loader' }
@ -51,19 +46,18 @@ module.exports = {
node: {
setImmediate: false
},
plugins: isDev ? [
plugins: [
new LodashModuleReplacementPlugin({
collections: true,
caching: true
})
].concat(isDev ? [
new webpack.HotModuleReplacementPlugin()
] : [
new webpack.DefinePlugin({
'process.browser': true,
'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
analyzerMode: 'static',
generateStatsFile: true,
@ -74,6 +68,6 @@ module.exports = {
openAnalyzer: false,
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'
}