I am using typescript + vue 3 to develop a google chrome extension, when I build my app, shows error like this:
Error: Module build failed (from ./node_modules/vue-loader/dist/stylePostLoader.js):
Error: PostCSS received undefined instead of CSS string
this is the package.json:
{
"name": "reddwaf-translate-plugin",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "rm -rf src/bundle && webpack --mode development --config src/resource/config/webpack.dev.config.js",
"build": "gulp --cwd . --gulpfile build/gulp-build.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jiangxiaoqiang/reddwaf-translate-plugin.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jiangxiaoqiang/reddwaf-translate-plugin/issues"
},
"homepage": "https://github.com/jiangxiaoqiang/reddwaf-translate-plugin#readme",
"devDependencies": {
"@babel/core": "^7.16.12",
"@babel/preset-env": "^7.16.11",
"@vue/compiler-sfc": "^3.2.29",
"babel-loader": "^8.2.3",
"copy-webpack-plugin": "^10.2.1",
"css-loader": "^6.5.1",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.5.3",
"sass-loader": "^12.4.0",
"ts-loader": "^9.2.6",
"typescript": "^4.5.5",
"vue-loader": "^17.0.0",
"webpack": "^5.67.0",
"webpack-cli": "^4.9.2"
},
"dependencies": {
"@types/chrome": "^0.0.177",
"@types/webextension-polyfill": "^0.8.2",
"vue": "^3.2.29",
"vuex": "^4.0.2"
}
}
and this is the webpack config:
const path = require('path');
const webpack = require( 'webpack' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin');
const HtmlWebpackPlugin = require( 'html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const { VueLoaderPlugin } = require("vue-loader");
module.exports = {
entry : {
'popup/popup' : './src/popup/'
} ,
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
// https://stackoverflow.com/questions/50805384/module-not-found-error-cant-resolve-vue-path-not-correct
vue: 'vue/dist/vue.esm-bundler.js'
},
},
output : {
path : path.resolve(__dirname, '../../bundle') ,
filename : '[name].js'
},
module : {
rules : [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/]
},
exclude: /node_modules/
},
{
test : /\.js$/ ,
exclude : [ /node_modules(?!(\/|\\?\\)(translation\.js|selection-widget|connect\.io|chrome-env)\1)/ ] ,
loader : 'babel-loader'
} ,
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test : /\.(scss)$/ ,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}
]
},
plugins : [
new VueLoaderPlugin(),
new CopyPlugin({
patterns: [
{ from: "src/manifest.json", to: "manifest.json" },
{ from: "src/resource/image", to: "resource/image" },
],
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
new HtmlWebpackPlugin({
filename: 'popup/popup.html',
template: 'src/popup/index.html'
}),
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: false,
__VUE_PROD_DEVTOOLS__: false,
}),
]
};
what should I do to fix this problem? I am searching from internet that someone told that the node-sass is not imcompatible, but I am not using node-sass right now. where is the problem?