http://webpack.github.io/docs/tutorials/getting-started/
npm install webpack -g
webpack ./entry.js bundle.js
条件:
- Create a empty node_modules folder.
- Run npm install css-loader style-loader inside the floder.
require("!style!css!./style.css"); //in entry.js
或者 better:
require("./style.css"); //in entry.js
webpack ./entry.js bundle.js --module-bind 'css=style!css' //in commend line
module.exports = {
entry: "./entry.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" }
]
}
};
webpack //命令
webpack --progress --colors --watch
webpack-dev-server --progress --colors //(需要npm install webpack-dev-server -g)
dev-server 地址: http://localhost:8080/webpack-dev-server/bundle