90 lines
2.1 KiB
JavaScript
90 lines
2.1 KiB
JavaScript
/* eslint-disable */
|
|
const path = require('path');
|
|
const webpack = require('webpack');
|
|
// const nodeExternals = require('webpack-node-externals');
|
|
const pkgs = require('./package.json');
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
|
/** 解决esmodule中noEmit报错问题 */
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
|
|
const ENV = process.env.ENV;
|
|
|
|
const plugins = [new ForkTsCheckerWebpackPlugin()];
|
|
if (ENV === 'init') {
|
|
plugins.push(
|
|
new CopyPlugin({
|
|
patterns: [{ from: 'src/app.config.json5', to: 'app.config.json5' }],
|
|
}),
|
|
);
|
|
}
|
|
/**
|
|
* @type {webpack.Configuration}
|
|
*/
|
|
module.exports = {
|
|
mode: 'production',
|
|
entry: path.join(__dirname, './src/index.ts'),
|
|
target: 'node',
|
|
// devtool: 'source-map',
|
|
output: {
|
|
path: path.join(__dirname, './dist'),
|
|
// path: path.join(__dirname, './dev-package'),
|
|
// filename: 'app.mjs',
|
|
filename: 'app.cjs',
|
|
// module: true,
|
|
// chunkFormat: 'module',
|
|
},
|
|
// experiments: {
|
|
// outputModule: true,
|
|
// },
|
|
optimization: {
|
|
minimize: false,
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.tsx?$/,
|
|
exclude: '/node_modules/',
|
|
use: {
|
|
loader: 'ts-loader',
|
|
options: {
|
|
allowTsInNodeModules: true,
|
|
transpileOnly: true, // 可选,加快构建速度
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
// 忽略特定警告
|
|
ignoreWarnings: [
|
|
{
|
|
message: /Critical dependency: the request of a dependency is an expression/,
|
|
},
|
|
{
|
|
message: /[DEP0040] DeprecationWarning: The `punycode`/,
|
|
},
|
|
],
|
|
|
|
resolve: {
|
|
extensions: ['.ts', '.js'],
|
|
alias: {
|
|
'@': path.join(__dirname, './src'),
|
|
// hexoid: 'hexoid/dist/index.js',
|
|
},
|
|
},
|
|
|
|
externals: {
|
|
sequelize: 'commonjs sequelize',
|
|
'socket.io': 'commonjs socket.io',
|
|
'@babel/preset-env': 'commonjs @babel/preset-env',
|
|
'@babel/preset-typescript': 'commonjs @babel/preset-typescript',
|
|
},
|
|
plugins: [...plugins],
|
|
node: {},
|
|
stats: {
|
|
errorDetails: true,
|
|
all: false,
|
|
errors: true,
|
|
warnings: false,
|
|
},
|
|
};
|