mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-16 20:14:35 +00:00
update to webpack 4
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
const webpack = require('webpack');
|
||||
const config = require('sapper/webpack/config.js');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||
|
||||
const isDev = config.dev;
|
||||
const mode = process.env.NODE_ENV;
|
||||
const isDev = mode === 'development';
|
||||
|
||||
module.exports = {
|
||||
entry: config.client.entry(),
|
||||
output: config.client.output(),
|
||||
resolve: {
|
||||
extensions: ['.js', '.html']
|
||||
extensions: ['.js', '.json', '.html']
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@@ -20,41 +20,16 @@ module.exports = {
|
||||
loader: 'svelte-loader',
|
||||
options: {
|
||||
hydratable: true,
|
||||
emitCss: !isDev,
|
||||
cascade: false,
|
||||
store: true,
|
||||
hotReload: true
|
||||
store: true
|
||||
}
|
||||
}
|
||||
},
|
||||
isDev && {
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{ loader: 'style-loader' },
|
||||
{ loader: 'css-loader' }
|
||||
]
|
||||
},
|
||||
!isDev && {
|
||||
test: /\.css$/,
|
||||
use: ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: [{ loader: 'css-loader', options: { sourceMap:isDev } }]
|
||||
})
|
||||
}
|
||||
].filter(Boolean)
|
||||
]
|
||||
},
|
||||
mode,
|
||||
plugins: [
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
minChunks: 2,
|
||||
async: false,
|
||||
children: true
|
||||
})
|
||||
].concat(isDev ? [
|
||||
new webpack.HotModuleReplacementPlugin()
|
||||
] : [
|
||||
new ExtractTextPlugin('main.css'),
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new UglifyJSPlugin()
|
||||
]).filter(Boolean),
|
||||
isDev && new webpack.HotModuleReplacementPlugin()
|
||||
].filter(Boolean),
|
||||
devtool: isDev && 'inline-source-map'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user