步驟:css
一、配置文件webpack.config.js:webpack
{web
test:/\.css$/,npm
loader:'style-loader!css-loader'ui
}spa
坑1:-loader尾綴test
坑2:Module build failed: Unknown word 模塊建立失敗:未知文字????import
解決方案:注掉整個css的配置,即:require
//{配置
//test:/\.css$/,
//loader:'style-loader!css-loader'
//}
二、入口文件main.js:
require('./assets/css/base.css');
或:import './assets/css/base.css';
三、$npm install style-loader css-loader --save-dev
四、調用css
<style>
@import './assets/css/base.css';
</style>