2018-12-11 15:31:48 +00:00
|
|
|
const config = require('sapper/config/webpack.js')
|
2018-12-16 01:36:36 +00:00
|
|
|
const terser = require('./terser.config')
|
2018-12-11 15:31:48 +00:00
|
|
|
const webpack = require('webpack')
|
2018-12-18 08:43:51 +00:00
|
|
|
const { mode, dev, resolve } = require('./shared.config')
|
2019-09-21 06:17:52 +00:00
|
|
|
const legacyBabel = require('./legacyBabel.config')
|
2018-12-11 15:31:48 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: config.serviceworker.entry(),
|
|
|
|
output: config.serviceworker.output(),
|
2018-12-18 08:43:51 +00:00
|
|
|
resolve,
|
2018-12-16 03:21:20 +00:00
|
|
|
mode,
|
|
|
|
devtool: dev ? 'inline-source-map' : 'source-map',
|
2019-09-21 06:17:52 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
process.env.LEGACY && legacyBabel()
|
|
|
|
].filter(Boolean)
|
|
|
|
},
|
2019-10-08 14:57:37 +00:00
|
|
|
optimization: dev ? {} : {
|
|
|
|
minimize: !process.env.DEBUG,
|
|
|
|
minimizer: [
|
|
|
|
terser()
|
|
|
|
]
|
|
|
|
},
|
2018-12-11 15:31:48 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
2018-12-16 01:36:36 +00:00
|
|
|
'process.browser': true,
|
2018-12-16 03:21:20 +00:00
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode),
|
2019-09-21 06:17:52 +00:00
|
|
|
'process.env.LEGACY': !!process.env.LEGACY,
|
2018-12-11 15:31:48 +00:00
|
|
|
'process.env.SAPPER_TIMESTAMP': process.env.SAPPER_TIMESTAMP || Date.now()
|
2019-10-08 14:57:37 +00:00
|
|
|
})
|
2019-09-21 20:44:32 +00:00
|
|
|
].filter(Boolean)
|
2018-12-11 15:31:48 +00:00
|
|
|
}
|