2021-07-05 04:19:04 +01:00
|
|
|
import { LOCALE } from '../src/routes/_static/intl.js'
|
|
|
|
import path from 'path'
|
|
|
|
import webpack from 'webpack'
|
|
|
|
import config from 'sapper/config/webpack.js'
|
|
|
|
import pkg from '../package.json'
|
|
|
|
import { mode, dev, resolve, inlineSvgs } from './shared.config.js'
|
2020-11-29 22:13:27 +00:00
|
|
|
|
2021-07-05 04:19:04 +01:00
|
|
|
const { version } = pkg
|
2018-12-11 15:31:48 +00:00
|
|
|
|
2019-08-26 02:33:44 +01: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 = [
|
2021-07-05 04:19:04 +01:00
|
|
|
'../_workers/blurhash.js',
|
2019-08-26 02:33:44 +01:00
|
|
|
'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',
|
2021-03-06 17:07:06 +00:00
|
|
|
'tesseract.js/src/createWorker.js',
|
|
|
|
'tesseract.js/src/createWorker.js.map'
|
2019-08-26 02:33:44 +01:00
|
|
|
]
|
|
|
|
|
2019-05-09 03:58:32 +01:00
|
|
|
const serverResolve = JSON.parse(JSON.stringify(resolve))
|
2020-09-13 21:37:54 +01:00
|
|
|
serverResolve.alias = serverResolve.alias || {}
|
2019-08-26 02:33:44 +01:00
|
|
|
NOOP_MODULES.forEach(mod => {
|
2021-07-05 04:19:04 +01:00
|
|
|
serverResolve.alias[mod] = '@stdlib/utils-noop'
|
2019-08-26 02:33:44 +01:00
|
|
|
})
|
2019-05-09 03:58:32 +01:00
|
|
|
|
2021-07-05 04:19:04 +01:00
|
|
|
export default {
|
2018-12-11 15:31:48 +00:00
|
|
|
entry: config.server.entry(),
|
|
|
|
output: config.server.output(),
|
|
|
|
target: 'node',
|
2019-05-09 03:58:32 +01:00
|
|
|
resolve: serverResolve,
|
2018-12-11 15:31:48 +00:00
|
|
|
externals: Object.keys(pkg.dependencies),
|
|
|
|
module: {
|
|
|
|
rules: [
|
2020-11-29 22:13:27 +00:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
2021-07-05 04:19:04 +01:00
|
|
|
loader: path.join(__dirname, './svelte-intl-loader.cjs')
|
2020-11-29 22:13:27 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-11 15:31:48 +00:00
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'svelte-loader',
|
|
|
|
options: {
|
|
|
|
css: false,
|
|
|
|
store: true,
|
|
|
|
generate: 'ssr',
|
|
|
|
dev
|
|
|
|
}
|
|
|
|
}
|
2020-11-29 22:13:27 +00:00
|
|
|
},
|
|
|
|
{
|
2021-07-05 04:19:04 +01:00
|
|
|
loader: path.join(__dirname, './svelte-intl-loader.cjs')
|
2018-12-11 15:31:48 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
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
|
|
|
},
|
2021-02-20 21:40:33 +00:00
|
|
|
optimization: dev ? {} : { minimize: false },
|
2019-03-03 03:02:06 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
2019-09-21 07:17:52 +01:00
|
|
|
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
|
2021-02-20 23:30:58 +00:00
|
|
|
'process.env.LOCALE': JSON.stringify(LOCALE),
|
2021-03-14 17:20:23 +00:00
|
|
|
'process.env.PINAFORE_VERSION': JSON.stringify(version),
|
|
|
|
'process.env.IS_SERVICE_WORKER': 'false'
|
2019-03-03 03:02:06 +00:00
|
|
|
})
|
|
|
|
]
|
2018-12-11 15:31:48 +00:00
|
|
|
}
|