webpack4搭建vue项目引入element-ui库,引入样式报错问题解决。

引入:
import ElementUI from “element-ui”;
import “element-ui/lib/theme-chalk/index.css”;
Vue.use(ElementUI);
报错信息
client:159 ./node_modules/element-ui/lib/theme-chalk/index.css 1:0
Module parse failed: Unexpected character ‘@’ (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
在webpack基础配置代码:

{
					//用来解析css文件
					test:/\.(css)$/,
					// exclude: /node_modules/,		一定不要加这行
					loader: 'style-loader!css-loader',
				},
				//解析el的文件
				{
					test: /\.(woff|svg|eot|ttf)\??.*$/,
					loader: 'url-loader'
				},

重启项目ok~~亲测,自己开发遇到的坑亲测!!!

猜你喜欢

转载自blog.csdn.net/Miss_hhl/article/details/103768314