作者:汪娇娇
时间:2017年8月11日
(1)全局:npm install -g webpack
(2)项目文件夹(cmd跳转到项目的文件夹):npm install --save-dev webpack
npm init
(1)npm install --save-dev style-loader css-loader
(2)npm install --save-dev url-loader
var webpack = require('webpack');
module.exports = {
entry: __dirname+'/app/main.js',
output: {
path: __dirname+'/public',
filename: 'bundle.js'
},
module: {
loaders: [
{test: /\.css$/,loader: 'style-loader!css-loader'},
{test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=8192'}
]
}
};
require('./main.css');
require('./Greeter.js');
<!-- index.html -->
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>