打包出错了
rules中增加以下规则:
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},//配置处理.css文件的第三方处理规则
然后去github里对应webpack版本下载安装对应的css-loader、style-loader版本依赖
我的依赖版本如下,可以作为参考:
"css-loader": "^6.7.1",
"style-loader": "^3.1.0",
"vue": "^2.6.10",
"vue-loader": "^15.7.0",
"vue-template-compiler": "^2.6.10",
"webpack": "^5.73.0"
const path = require('path')const VueLoaderPlugin = require('vue-loader/lib/plugin')const htmlWebpackplugin = require('html-webpack-plugin');module.exports = {entry: path.join(__dirname, 'src/index.js'),output: {filename: 'bundle.js',path: path.join(__dirname, "dist")},module: {rules: [// {// test: /\.(vue|js|jsx)$/,// loader: 'eslint-loader',// exclude: /node_modules/,// enforce: 'pre'// },{test: /\.vue$/,loader: 'vue-loader'},{test: /\.css$/,loader: 'css-loader'},{test: /\.styl/,use: ['style-loader','css-loader','stylus-loader']}]},plugins: [new htmlWebpackplugin({}),new VueLoaderPlugin()],mode: 'development'}
谢谢楼主!照你的方法 生成dist了。
这个我解决了,webpack版本过高的话需要安装html-webpack-plugin和vue-loader-plugin插件,然后webpack.config.js的配置如下:
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const htmlWebpackplugin = require('html-webpack-plugin');
module.exports = {
entry:path.join(__dirname,'src/index.js'),
output:{
filename:'bundle.js',
path:path.join(__dirname,'dist')
},
module:{
rules:[
{
test:/\.vue$/,
loader:'vue-loader'
},
{
test: /\.css$/,
loader: 'css-loader'
},
{
test:/\.styl/,
use:[
'style-loader',
'css-loader',
'stylus-loader'
]
},
{
test:/\.(gif|jpg|jpeg|png|svg)$/,
use:[
{
loader:'url-loader',
options:{
limit:1024,
name:'[name]-aaa.[ext ]'
}
}
]
}
]
},
plugins: [
new htmlWebpackplugin({
}),
new VueLoaderPlugin()
],
}
我也是这个问题