Changeset View
Changeset View
Standalone View
Standalone View
web/webpack.config.cjs
const AssetsPlugin = require('assets-webpack-plugin'); | const AssetsPlugin = require('assets-webpack-plugin'); | ||||
const CopyPlugin = require('copy-webpack-plugin'); | const CopyPlugin = require('copy-webpack-plugin'); | ||||
const path = require('path'); | const path = require('path'); | ||||
const { | const { | ||||
createProdBrowserConfig, | createProdBrowserConfig, | ||||
createDevBrowserConfig, | createDevBrowserConfig, | ||||
createNodeServerRenderingConfig, | createNodeServerRenderingConfig, | ||||
createWebWorkersConfig, | |||||
} = require('lib/webpack/shared.cjs'); | } = require('lib/webpack/shared.cjs'); | ||||
const babelConfig = require('./babel.config.cjs'); | const babelConfig = require('./babel.config.cjs'); | ||||
const baseBrowserConfig = { | const baseBrowserConfig = { | ||||
plugins: [ | plugins: [ | ||||
new CopyPlugin({ | new CopyPlugin({ | ||||
patterns: [ | patterns: [ | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | const baseNodeServerRenderingConfig = { | ||||
output: { | output: { | ||||
filename: 'app.build.cjs', | filename: 'app.build.cjs', | ||||
library: 'app', | library: 'app', | ||||
libraryTarget: 'commonjs2', | libraryTarget: 'commonjs2', | ||||
path: path.join(__dirname, 'dist'), | path: path.join(__dirname, 'dist'), | ||||
}, | }, | ||||
}; | }; | ||||
const baseWebWorkersConfig = { | |||||
entry: { | |||||
pushNotif: './push-notif/service-worker.js', | |||||
}, | |||||
output: { | |||||
filename: '[name].build.js', | |||||
path: path.join(__dirname, 'dist', 'webworkers'), | |||||
}, | |||||
}; | |||||
module.exports = function (env) { | module.exports = function (env) { | ||||
const browserConfig = env.prod | const browserConfig = env.prod | ||||
? createProdBrowserConfig(baseProdBrowserConfig, babelConfig) | ? createProdBrowserConfig(baseProdBrowserConfig, babelConfig) | ||||
: createDevBrowserConfig(baseDevBrowserConfig, babelConfig); | : createDevBrowserConfig(baseDevBrowserConfig, babelConfig); | ||||
const nodeConfig = createNodeServerRenderingConfig( | const nodeConfig = createNodeServerRenderingConfig( | ||||
baseNodeServerRenderingConfig, | baseNodeServerRenderingConfig, | ||||
babelConfig, | babelConfig, | ||||
); | ); | ||||
const nodeServerRenderingConfig = { | const nodeServerRenderingConfig = { | ||||
...nodeConfig, | ...nodeConfig, | ||||
mode: env.prod ? 'production' : 'development', | mode: env.prod ? 'production' : 'development', | ||||
}; | }; | ||||
return [browserConfig, nodeServerRenderingConfig]; | const webWorkersConfig = createWebWorkersConfig( | ||||
env, | |||||
baseWebWorkersConfig, | |||||
babelConfig, | |||||
); | |||||
return [browserConfig, nodeServerRenderingConfig, webWorkersConfig]; | |||||
}; | }; |