我有一个问题与terser-webpack-plugin我不能缩小我的捆绑错误是
来自Terser的Data.js中出错Data.js无效赋值
我有“terser-webpack-plugin”的版本:“4.2.3”,“webpack”:“^4.33.0”,“clean-webpack-plugin”:“^3.0.0”,“dotenv-webpack”:“^1.7.0”和React 17.0.0
这里你可以看到我的webpack配置
const HtmlWebpackPlugin = require('html-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { EnvironmentPlugin, ProgressPlugin } = require('webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const modeConfig = (env, target) => require(`./build-utils/webpack.${env}`)(target);
const presetConfig = require('./build-utils/loadPresets');
const targetUtils = require('./build-utils/targetUtils');
module.exports = ({ mode, presets, target } = { mode: 'production', presets: [] }) => {
return webpackMerge(
{
mode, // minify the code in production mode
entry: './src/index.tsx',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.build.json',
},
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.json', '.js'],
plugins: [new TsconfigPathsPlugin()],
},
plugins: [
new CleanWebpackPlugin(),
new Dotenv({ path: targetUtils.getEnvFile(target), systemvars: true }),
new ProgressPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(rootDir, 'index.html'),
mode,
}),
new EnvironmentPlugin(process.env),
],
externals: targetUtils.getExternals(target),
node: {
fs: 'empty',
},
},
modeConfig(mode, target),
presetConfig({ mode, presets }),
);
};
个字符
1条答案
按热度按时间luaexgnf1#
我通过使用新的加载器来支持Webpack 5和TS-LOADER沿着Webpack 5的其他更新来解决这个问题。