鲜荣彬
Herry

在webpackDemo 文件夹中新建 style.css,index.html

style.css 中将背景色设为红色。

body{
    background-color: red;
}

he'llWorld.js

require('./test.js');
require('./style.css'); function hello(){ console.log("Hello, Webpack!"); } hello();


运行命令,会报错,如下图:

  

  这是因为没有 css解析器的原因,需要安装 style-loader、css-loader.

  命令如下

npm install css-loader style-loader --save-dev

  然后,将require语句改成

require('style-loader!css-loader!./style.css');

  重新运行即可

  

posted on 2017-02-22 21:02  Herry彬  阅读(2989)  评论(0编辑  收藏  举报