I had the same error. @sebastian & @Mattias helped me to get the exact solution.
My configuration is
const { VueLoaderPlugin } = require("vue-loader");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
mode: "development",
entry: "./src/main.ts",
target: "web",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js",
publicPath: "/",
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".vue", ".json"],
alias: {
"@/": path.resolve(__dirname, "src"),
"@/vuex": path.resolve(__dirname, "src/vuex"),
},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
include: /src/,
loader: "ts-loader",
options: {
transpileOnly: true,
appendTsSuffixTo: [/\.vue$/],
},
},
{
test: /\.vue$/,
loader: "vue-loader",
options: {
loaders: {
scss: "vue-style-loader!css-loader!sass-loader",
sass: "vue-style-loader!css-loader!sass-loader?indentedSyntax",
},
},
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.s[ac]ss$/i,
use: ["vue-style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(png|svg|jpe?g|gif)$/i,
loader: "file-loader",
options: {
outputPath: "assets",
},
},
],
},
plugins: [
new VueLoaderPlugin(),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "public", "index.html"),
filename: "index.html",
favicon: "./public/favicon.ico",
}),
// make sure to include the plugin for the magic
],
optimization: {
moduleIds: "hashed",
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
priority: -10,
chunks: "all",
},
},
},
},
};
Focus on this part
resolve: {
extensions: [".ts", ".tsx", ".js", ".vue", ".json"],
alias: {
"@/": path.resolve(__dirname, "src"),
"@/vuex": path.resolve(__dirname, "src/vuex"),
},
},
The custom defined resolve function didn't work for me but directly using the path.resolve() function helped me to avoid this error.
compilerOptionsis for TypeScript... that's different from webpack and vuejs. Are you using TS in your project? Can you share more code?