1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-11 09:45:24 +01:00
Pinafore-Web-Client-Frontend/webpack/server.config.js
Nolan Lawson 16e66346d7
fix!: remove esm package, use native Node ES modules (#2064)
BREAKING CHANGE: Node v12.20+, v14.14+, or v16.0+ is required

* fix!: remove esm package, use native Node ES modules

* fix: fix some CJS imports
2021-07-04 20:19:04 -07:00

75 lines
2.0 KiB
JavaScript

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'
const { version } = pkg
// 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.js',
'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/src/createWorker.js',
'tesseract.js/src/createWorker.js.map'
]
const serverResolve = JSON.parse(JSON.stringify(resolve))
serverResolve.alias = serverResolve.alias || {}
NOOP_MODULES.forEach(mod => {
serverResolve.alias[mod] = '@stdlib/utils-noop'
})
export default {
entry: config.server.entry(),
output: config.server.output(),
target: 'node',
resolve: serverResolve,
externals: Object.keys(pkg.dependencies),
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: path.join(__dirname, './svelte-intl-loader.cjs')
}
},
{
test: /\.html$/,
exclude: /node_modules/,
use: {
loader: 'svelte-loader',
options: {
css: false,
store: true,
generate: 'ssr',
dev
}
}
},
{
loader: path.join(__dirname, './svelte-intl-loader.cjs')
}
]
},
mode,
performance: {
hints: false // it doesn't matter if server.js is large
},
optimization: dev ? {} : { minimize: false },
plugins: [
new webpack.DefinePlugin({
'process.env.INLINE_SVGS': JSON.stringify(inlineSvgs),
'process.env.LOCALE': JSON.stringify(LOCALE),
'process.env.PINAFORE_VERSION': JSON.stringify(version),
'process.env.IS_SERVICE_WORKER': 'false'
})
]
}