已經(jīng)安裝了css-loader,為什么會報這個錯誤呢?
代碼如下:
const?path?=?require('path');
const?VueLoaderPlugin?=?require('vue-loader/lib/plugin');
module.exports?=?{
??mode:?'development',
??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$/,
????????use:[
??????????'style-loader',
??????????'css-loader'
????????]
??????},
??????{
????????test:?/\.js?$/,
????????loader:?'babel-loader'
??????},
??????{
????????test:?/\.(jpg|jpeg|gif|bmp|png)$/,
????????use:[
??????????{
????????????loader:?'url-loader',
????????????options:?{
??????????????limit:?1024,
??????????????name:?'[name]-[hash].[ext]'
????????????}
??????????}
????????]
??????},
??????{
????????test:?/\.styl/,
????????use:[
??????????'style-loader',
??????????'css-loader,',
??????????'stylus-loader'
????????]
??????}
????]
??},
??plugins:[
????new?VueLoaderPlugin()
??]
}import?Vue?from?'vue'
import?App?from?'./app.vue'
import?'./assets/styles/text.css'
import?'./assets/img/1.jpg'
import?'./assets/styles/test.styl'
const?root?=?document.createElement("div");
document.body.appendChild(root);
new?Vue({
????render:function(h){
????????return?h(App)
????}
}).$mount(root);

請問大家,這是什么原因呢?
2018-07-18
css-loader處明顯多了一個逗號,另外,/\.styl/最好改成/\.styl(us)?$/,?不然在vue組件內(nèi)的style模板聲明 lang='stylus'后會報錯。改完了表示即可以編譯.styl文件,也可以編譯vue組件內(nèi)的stylus,正則表達式中最好添加$表示匹配結(jié)束。
2018-07-18
檢查node_modules文件夾里面有沒有style-loader這個包,css-loader應(yīng)該要依賴這個包,如果沒有安裝試一下,或者node_modules文件夾如果有vue-style-loader這個包,把規(guī)則里的style-loader改成這個