課程
/前端開發(fā)
/前端工具
/Vue+Webpack打造todo應(yīng)用
打包出錯(cuò)了
2021-01-25
源自:Vue+Webpack打造todo應(yīng)用 2-1
正在回答
rules中增加以下規(guī)則:
{? ? ? ? ? ? ? ? test: /\.css$/,? ? ? ? ? ? ? ? use: ['style-loader', 'css-loader']? ? ? ? ? ? },//配置處理.css文件的第三方處理規(guī)則
{
? ? ? ? ? ? ? ? test: /\.css$/,
? ? ? ? ? ? ? ? use: ['style-loader', 'css-loader']
? ? ? ? ? ? },//配置處理.css文件的第三方處理規(guī)則
然后去github里對(duì)應(yīng)webpack版本下載安裝對(duì)應(yīng)的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"
? ? "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了。
慕移動(dòng)9059126
這個(gè)我解決了,webpack版本過(guò)高的話需要安裝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)$/,
? ? ? ? ? ? {
? ? ? ? ? loader:'url-loader',
? ? ? ? ? ? options:{
? ? ? ? ? ? limit:1024,
? ? ? ? ? ? name:'[name]-aaa.[ext ]'
? ? ? ? ? ? }
? ? ? ? ??
? ? ? ? }
]
plugins: [
? ? ? ? new htmlWebpackplugin({
? ? ? ? }),
? ? ? ? new VueLoaderPlugin()
? ? ],
}
我也是這個(gè)問(wèn)題
舉報(bào)
用前端最熱門框架Vue+最火打包工具Webpack打造todo應(yīng)用
1 回答打包時(shí)報(bào)這個(gè)錯(cuò)誤怎么解決呢?感謝
5 回答這個(gè)怎么解決
2 回答這種報(bào)錯(cuò)是什么原因?怎么解決?
1 回答老師我這個(gè)都根您都一樣,這個(gè)報(bào)錯(cuò)怎么解決
3 回答請(qǐng)問(wèn)footer.jsx報(bào)錯(cuò)怎么解決?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2022-08-02
rules中增加以下規(guī)則:
然后去github里對(duì)應(yīng)webpack版本下載安裝對(duì)應(yīng)的css-loader、style-loader版本依賴
我的依賴版本如下,可以作為參考:
2021-04-07
2021-04-02
謝謝樓主!照你的方法 生成dist了。
2021-03-19
這個(gè)我解決了,webpack版本過(guò)高的話需要安裝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()
? ? ],
}
2021-03-16
我也是這個(gè)問(wèn)題