-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathwebpack.config.js
More file actions
40 lines (39 loc) · 1.13 KB
/
Copy pathwebpack.config.js
File metadata and controls
40 lines (39 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* webpack是一款模块加载器兼打包工具,
* 它能把各种资源,例如JS(含JSX)、coffee、样式(含less/sass)、图片等都作为模块来使用和处理。
*/
const path = require('path')
const webpack = require('webpack')
module.exports = {
entry: {
app: [ "webpack-hot-middleware/client?reload=1", "./src/client/index.js" ] //热加载
},
output: {
path: __dirname,
filename: 'bundle.js',
publicPath: '/dist/'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
],
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
include: [
path.join(__dirname, 'src/client'),
path.join(__dirname, 'src/server/shared')
],
query: {
presets: [ 'es2015', 'react'],
plugins: [['import', { libraryName: 'antd', style: true}]], //使用 babel-plugin-import 来进行按需加载
}
},{
test: /\.less$/,
use: [{loader: 'style-loader'}, {loader: 'css-loader'}, {loader: 'less-loader'}]
}]
}
}