2019-03-03 03:02:06 +00:00
|
|
|
const webpack = require('webpack')
|
2018-12-11 15:31:48 +00:00
|
|
|
const config = require('sapper/config/webpack.js')
|
|
|
|
const pkg = require('../package.json')
|
2019-09-21 06:17:52 +00:00
|
|
|
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
|
2019-10-08 14:57:37 +00:00
|
|
|
const terser = require('./terser.config')
|
2018-12-11 15:31:48 +00:00
|
|
|
|
2019-08-26 01:33:44 +00:00
|
|
|
// modules that the server should ignore, either because they cause errors or warnings
|
|
|
|
// (because they're only used on the client side)
|
|
|
|
const NOOP_MODULES = [
|
|
|
|
'page-lifecycle/dist/lifecycle.mjs',
|
|
|
|
'../_workers/blurhash',
|
|
|
|
'tesseract.js/dist/worker.min.js',
|
|
|
|
'tesseract.js/dist/worker.min.js.map',
|
|
|
|
'tesseract.js-core/tesseract-core.wasm',
|
|
|
|
'tesseract.js-core/tesseract-core.wasm.js',
|
|
|
|
'tesseract.js'
|
|
|
|
]
|
|
|
|
|
2019-05-09 02:58:32 +00:00
|
|
|
const serverResolve = JSON.parse(JSON.stringify(resolve))
|
2019-08-26 01:33:44 +00:00
|
|
|
NOOP_MODULES.forEach(mod => {
|
|
|
|
serverResolve.alias[mod] = 'lodash-es/noop'
|
|
|
|
})
|
2019-05-09 02:58:32 +00:00
|
|
|
|
2018-12-11 15:31:48 +00:00
|
|
|
module.exports = {
|
|
|
|
entry: config.server.entry(),
|
|
|
|
output: config.server.output(),
|
|
|
|
target: 'node',
|
2019-05-09 02:58:32 +00:00
|
|
|
resolve: serverResolve,
|
2018-12-11 15:31:48 +00:00
|
|
|
externals: Object.keys(pkg.dependencies),
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'svelte-loader',
|
|
|
|
options: {
|
|
|
|
css: false,
|
|
|
|
store: true,
|
|
|
|
generate: 'ssr',
|
|
|
|
dev
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2018-12-16 03:21:20 +00:00
|
|
|
mode,
|
2018-12-11 15:31:48 +00:00
|
|
|
performance: {
|
|
|
|
hints: false // it doesn't matter if server.js is large
|
2019-03-03 03:02:06 +00:00
|
|
|
},
|
2019-10-08 14:57:37 +00:00
|
|
|
optimization: dev ? {} : {
|
|
|
|
minimize: !process.env.DEBUG,
|
|
|
|
minimizer: [
|
|
|
|
terser()
|
|
|
|
]
|
|
|
|
},
|
2019-03-03 03:02:06 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
2019-09-21 06:17:52 +00:00
|
|
|
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
|
|
|
|
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
|
|
|
|
'process.env.LEGACY': !!process.env.LEGACY
|
2019-03-03 03:02:06 +00:00
|
|
|
})
|
|
|
|
]
|
2018-12-11 15:31:48 +00:00
|
|
|
}
|