2020-02-16 18:30:00 +00:00
|
|
|
const path = require('path')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
|
|
|
|
const {
|
|
|
|
dependencies,
|
|
|
|
devDependencies,
|
|
|
|
productName,
|
|
|
|
} = require('../package.json')
|
|
|
|
|
|
|
|
const externals = Object.keys(dependencies).concat(Object.keys(devDependencies))
|
|
|
|
const isDevMode = process.env.NODE_ENV === 'development'
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
name: 'workers',
|
|
|
|
mode: process.env.NODE_ENV,
|
2021-03-03 03:51:01 +00:00
|
|
|
devtool: isDevMode ? 'eval-cheap-module-source-map' : false,
|
2020-02-16 18:30:00 +00:00
|
|
|
entry: {
|
2022-05-31 20:15:44 +00:00
|
|
|
workerSample: path.join(__dirname, '../src/utilities/workerSample.js'),
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
libraryTarget: 'commonjs2',
|
|
|
|
path: path.join(__dirname, '../dist'),
|
|
|
|
filename: '[name].js',
|
|
|
|
},
|
|
|
|
externals: externals,
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2022-07-14 14:43:07 +00:00
|
|
|
test: /\.js$/,
|
2020-02-16 18:30:00 +00:00
|
|
|
use: 'babel-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
2021-03-03 03:51:01 +00:00
|
|
|
loader: 'node-loader',
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
__dirname: isDevMode,
|
|
|
|
__filename: isDevMode,
|
2021-03-03 03:51:01 +00:00
|
|
|
global: isDevMode,
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
// new WriteFilePlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.PRODUCT_NAME': JSON.stringify(productName),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.join(__dirname, '../src/'),
|
|
|
|
src: path.join(__dirname, '../src/'),
|
|
|
|
},
|
2022-05-31 20:15:44 +00:00
|
|
|
extensions: ['.js', '.json'],
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
target: 'node',
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust rendererConfig for production settings
|
|
|
|
*/
|
|
|
|
if (isDevMode) {
|
|
|
|
// any dev only config
|
2020-03-24 13:22:29 +00:00
|
|
|
} else {
|
|
|
|
config.plugins.push(
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
minimize: true,
|
|
|
|
})
|
|
|
|
)
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = config
|