2019-03-03 04:02:06 +01:00
|
|
|
const webpack = require('webpack')
|
2018-12-11 16:31:48 +01:00
|
|
|
const config = require('sapper/config/webpack.js')
|
|
|
|
const pkg = require('../package.json')
|
2019-09-21 08:17:52 +02:00
|
|
|
const { mode, dev, resolve, inlineSvgs, allSvgs } = require('./shared.config')
|
2018-12-11 16:31:48 +01:00
|
|
|
|
2019-08-26 03:33:44 +02: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 = [
|
|
|
|
'../_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 04:58:32 +02:00
|
|
|
const serverResolve = JSON.parse(JSON.stringify(resolve))
|
2019-08-26 03:33:44 +02:00
|
|
|
NOOP_MODULES.forEach(mod => {
|
|
|
|
serverResolve.alias[mod] = 'lodash-es/noop'
|
|
|
|
})
|
2019-05-09 04:58:32 +02:00
|
|
|
|
2018-12-11 16:31:48 +01:00
|
|
|
module.exports = {
|
|
|
|
entry: config.server.entry(),
|
|
|
|
output: config.server.output(),
|
|
|
|
target: 'node',
|
2019-05-09 04:58:32 +02:00
|
|
|
resolve: serverResolve,
|
2018-12-11 16:31:48 +01: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 04:21:20 +01:00
|
|
|
mode,
|
2018-12-11 16:31:48 +01:00
|
|
|
performance: {
|
|
|
|
hints: false // it doesn't matter if server.js is large
|
2019-03-03 04:02:06 +01:00
|
|
|
},
|
2019-10-08 16:57:37 +02:00
|
|
|
optimization: dev ? {} : {
|
2019-10-10 15:02:18 +02:00
|
|
|
minimize: false
|
2019-10-08 16:57:37 +02:00
|
|
|
},
|
2019-03-03 04:02:06 +01:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
2019-09-21 08:17:52 +02:00
|
|
|
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
|
|
|
|
'process.env.ALL_SVGS': JSON.stringify(allSvgs),
|
|
|
|
'process.env.LEGACY': !!process.env.LEGACY
|
2019-03-03 04:02:06 +01:00
|
|
|
})
|
|
|
|
]
|
2018-12-11 16:31:48 +01:00
|
|
|
}
|