-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.config.example.js
executable file
·68 lines (66 loc) · 1.96 KB
/
webpack.config.example.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var path = require('path');
var project = require('./package.json');
var node_modules = path.resolve(__dirname, 'node_modules');
var react = path.resolve(node_modules, 'react/dict/react.js');
var autoprefixer = require("autoprefixer");
var process = require('process');
var ENV = process.env.NODE_ENV;
var config = {
entry:{
'example':'./example/example.jsx'
},
output:{
//publicPath:"./dist/",
publicPath:ENV == 'development' ? "http://localhost:8008/example/dist/" : "./dist/",
path:"./example/dist/",
filename:'example.js',
chunkFilename:'chunk/[name].[chunkhash:8].js'
},
externals: [
{
"jquery": "jQuery",
"react": "React",
"react-dom": "ReactDOM",
"zepto": "Zepto"
},
require('webpack-require-http')
],
module:{
loaders:[
{
test:/\.(jsx)?$/,
exclude:/(node_modules)/,
loader: 'babel',
query:{
presets:['es2015', 'stage-0', 'react']
}
},
{
test:/\.(scss|sass)?$/,
exclude:/(node_modules)/,
loader:'style!css!postcss!sass'
},
{
test:/\.css?$/,
//注意,因为例如ImageEditor.jsx/Slider.jsx代码中引用了node_modules下的css,所以此处不能排除掉node_modules目录
loader:'style!css'
},
{
test: /\.md$/,
loader: "html!markdown"
},
{
test:/\.(jpg|png|gif|jpeg)?$/,
loader:'url'
}
],
noParse:[react]
},
postcss: [ autoprefixer({ browsers: ['> 0.1%'] }) ],
resolve:{
alias:{
"react-component-lib":ENV == 'development' ? "../src/js/rui.jsx" : '../dist/bundle.js'
}
}
};
module.exports = config;