javascript - Webpack - 节点模块'TypeError:...替换不是函数'
问题描述
我试过查看这样的相关答案,但它们都非常不同,所以希望有人可以指导我。我对 webpack 很陌生,刚刚将我的烧瓶应用程序更新为新的引导程序主题。我突然在 docker build 中收到错误命令yard run
。有趣的是以前的 git commit 构建得很好,当我恢复它时,它现在也得到了同样的错误。
TypeError: previousExtractedCommentsSource.replace is not a function
at Object.callback (/app/assets/node_modules/terser-webpack-plugin/dist/index.js:320:43)
at enqueue (/app/assets/node_modules/terser-webpack-plugin/dist/index.js:450:14)
这个答案表明它可能是代码错字,但如果是这样,我将如何找到它?
我的 webpack.config.js,如果有帮助的话:
var { merge } = require('webpack-merge');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
var TerserPlugin = require('terser-webpack-plugin');
var common = {
watchOptions: {
poll: (process.env.WEBPACK_WATCHER_POLL || 'true') === 'true'
},
module: {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/],
loader: 'babel-loader'
},
{
test: [/\.scss$/, /\.css$/],
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader'
]
},
{
test: /\.(png|jpg|gif|svg)$/,
exclude: /fonts/,
loader: 'file-loader?name=/images/[name].[ext]'
},
{
test: /\.(ttf|eot|svg|woff2?)$/,
exclude: /images/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
publicPath: '../fonts'
}
}]
}
]
},
optimization: {
minimizer: [
new TerserPlugin({cache: true, parallel: true, sourceMap: false}),
new OptimizeCSSAssetsPlugin({})
]
}
};
module.exports = [
merge(common, {
entry: [
__dirname + '/app/app.scss',
__dirname + '/app/app.js'
],
output: {
path: __dirname + '/../public',
filename: 'js/app.js'
},
resolve: {
modules: [
'/node_modules',
__dirname + '/app'
]
},
plugins: [
new CopyWebpackPlugin({patterns: [{from: __dirname + '/static'}]}),
new MiniCssExtractPlugin({filename: 'css/app.css'}),
new webpack.ProvidePlugin({$: 'jquery', jQuery: 'jquery'}),
]
})
];
我会很感激任何帮助。谢谢
解决方案
推荐阅读
- json - 使用 thymeleaf 在浏览器中打印 Spring Boot JSON RESTful 响应
- networking - 如何通过网关通过内部网络在虚拟机上启用 Internet?
- php - PHP在没有API的情况下检查youtube频道是否存在
- node.js - 无法安装“@angular/cli”
- highcharts - Highchart 热图:排除颜色轴的总行
- macos - MTLArgumentEncoder 的初始化
- c# - 只记录某些代码,而忽略所有其他代码?
- python - 使用脚本获取零件的总质量
- html - 如何在同一个元素中同时选择和输入?
- javascript - 如何使用 ReactJS 在 Chrome 扩展中执行 document.write 突出显示的文本