При запуске webpack 4 с mode: production
я получил следующую ошибку:
ERROR in style.ba47861224d5cf44f61f.js from UglifyJs
Unexpected character '@' [./app/scss/main/app.scss:1,0][style.ba47861224d5cf44f61f.js:1,0]
Вот мой конфиг:
common.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
entry: {
index: "./webpack.entry.js",
style: "./app/scss/main/app.scss"
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
cacheDirectory: true
}
}
}
]
},
plugins: [
new CleanWebpackPlugin(["dist"]),
new HtmlWebpackPlugin({
template: "./app/html/index.html"
})
],
output: {
path: path.resolve(__dirname, "dist")
}
};
webpack.dev.js
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const webpack = require("webpack");
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const extractSass = new ExtractTextPlugin({
filename: "[name].[chunkhash].js"
});
module.exports = merge(common, {
devtool: "source-map",
module: {
rules: [
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{
loader: "css-loader",
options: {
sourceMap: true,
url: false
}
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
}
]
})
}
]
},
plugins: [extractSass, new webpack.HashedModuleIdsPlugin()],
output: {
filename: "[name].[chunkhash].js"
},
mode: "production"
});
Я не понимаю, почему UglifyJ жалуются на специальный символ '@'. Разве такие символы не должны быть удалены из css-loader
уже?