webpack中import引入css文件就报错

报错信息

clipboard.png

main.js

import vue from 'vue';
import vueRouter from 'vue-router';
import app from './app.vue';
import routes from './routes/routes.js';



vue.use( vueRouter );
let router = new vueRouter();
router.addRoutes( routes );
 
import './css/global.css';   //此行会报错


new vue({
    el:'#app',
    router,
    render: c => c(app)
});

webpack.config.js

    module:{
        rules:[
            {
                test:/\.css$/,
                loader:'style-loader!css-loader!autoprefixer'
            },{
                test:/\.js$/,
                loader:'babel-loader',
                exclude:/node_modules/
            },{
                test:/\.(png|jpe|jpeg|gif|svg)$/,
                loader:'file-loader',
                query:{
                    name:'dist/imges/[name][hash:8].[ext]'
                }
            },{
                test:/\.vue$/,
                loader:'vue-loader'
            },{
                test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
                loader: 'file-loader',
                query:{
                    name:'dist/fonts/[name][hash:8].[ext]'
                }
            }
        ]
    },
阅读 8.1k
1 个回答

css放在style标签里面导入
clipboard.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏