2021-12-21 16:56:24 +00:00
|
|
|
const path = require('path')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
const NodemonPlugin = require('nodemon-webpack-plugin')
|
2021-07-02 17:57:06 +00:00
|
|
|
|
2021-12-21 16:56:24 +00:00
|
|
|
module.exports = env => {
|
|
|
|
const isProduction = !!env.production
|
2022-03-05 10:40:50 +00:00
|
|
|
const generateSourceMap = !!env.sourcemap
|
2022-03-05 12:17:45 +00:00
|
|
|
let devtool = false
|
2022-03-05 10:40:50 +00:00
|
|
|
if (!isProduction) {
|
|
|
|
devtool = generateSourceMap ? 'source-map' : 'eval'
|
|
|
|
}
|
2021-12-21 16:56:24 +00:00
|
|
|
const config = {
|
|
|
|
mode: isProduction ? 'production' : 'development',
|
2022-02-05 00:15:26 +00:00
|
|
|
entry: './src/index.ts',
|
2022-03-05 10:40:50 +00:00
|
|
|
devtool,
|
2021-12-21 16:56:24 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js']
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
|
|
|
filename: 'app.js',
|
|
|
|
sourceMapFilename: '[file].map',
|
|
|
|
library: {
|
|
|
|
name: 'DeemixServer',
|
|
|
|
type: 'umd'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
target: 'node',
|
|
|
|
plugins: [
|
|
|
|
new NodemonPlugin(),
|
|
|
|
new webpack.DefinePlugin({ 'global.GENTLY': false }),
|
|
|
|
new webpack.ContextReplacementPlugin(/[/\\](express|keyv)[/\\]/, data => {
|
|
|
|
delete data.dependencies[0].critical
|
|
|
|
return data
|
|
|
|
}),
|
|
|
|
new webpack.ContextReplacementPlugin(/yargs/)
|
|
|
|
]
|
|
|
|
}
|
2021-07-02 17:57:06 +00:00
|
|
|
|
2021-12-21 16:56:24 +00:00
|
|
|
return config
|
|
|
|
}
|