Я использую Webpack 4 и получаю сообщение об ошибке при сборке приложения.Я также приложил снимок ошибки, с которой я столкнулся, и код конфигурации Webpack.
Пожалуйста, помогите мне решить эту проблему.Я использую: ОС: Ubuntu 18.04, Webpack: 4 NodeJs: NodeJS LTS 10, NPM: 5.6.0
Снимок ошибки здесь
Мой Webpack.config.prod.js Конфиг:
var webpack = require('webpack');
var path = require('path');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// var OfflinePlugin = require('offline-plugin')
// const CompressionPlugin = require("compression-webpack-plugin")
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports = {
entry: {
'/js/app': './frontend/app.js'
},
output: {
filename: 'app.js',
chunkFilename: '[name].js',
publicPath: "/public/js/",
path: path.resolve(__dirname, 'public', 'js')
},
module: {
rules: [
{
test: /jquery.+\.js$/,
use: [{
loader: 'expose-loader',
options: 'jQuery'
},{
loader: 'expose-loader',
options: '$'
}]
},
{
test: /\.(scss|css|sass)$/i,
use: [
// {
// loader: MiniCssExtractPlugin.loader,
// options: {
// // you can specify a publicPath here
// // by default it use publicPath in webpackOptions.output
// publicPath: '../'
// }
// },
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "sass-loader",
options: {
includePaths: [
path.resolve("./node_modules/")
]
}
}
]
},
{
test: /\.js$/,
loader: "babel-loader",
include: [
path.resolve(__dirname, "frontend"),
],
exclude: [
path.resolve(__dirname, "node_modules")
],
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
loader: 'url-loader?limit=4096&name=[name]-[hash].[ext]'
},
{
test: /\.json$/,
loader: 'json-loader',
type: "javascript/auto"
}
]},
node: {
fs: "empty",
net: "empty"
},
optimization: {
minimizer: [new UglifyJsPlugin()]
},
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
plugins: [
new BundleAnalyzerPlugin({
analyzerHost: "0.0.0.0"
}),
new UglifyJsPlugin({
test: /\.js(\?.*)?$/i,
parallel: true,
extractComments: 'all'
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.optimize\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
canPrint: true
})
]
}