-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.dev.js
70 lines (69 loc) · 1.87 KB
/
webpack.dev.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
69
70
/**
* Test Component for tingle
* @author fushan
*
* Copyright 2014-2016, Tingle Team.
* All rights reserved.
*/
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
module.exports = {
cache: false,
entry: {
demo: __dirname + '/demo/src/app/app.js'
},
output: {
path: __dirname + '/dist/demo',
filename: "[name].js",
sourceMapFilename: "[name].js.map"
},
devtool: '#source-map', // 这个配置要和output.sourceMapFilename一起使用
module: {
loaders: [
{
test: /\.js$/,
// tingle以外的modules都不需要经过babel解析
exclude: [path.join(__dirname, 'node_modules'), path.join(__dirname, 'dist')],
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-1'],
plugins: ['add-module-exports'],
compact: false
}
},
{
test: /\.svg$/,
loader: 'babel?presets[]=react,presets[]=es2015,presets[]=stage-1!svg-react?attrs={style:{}}',
}
]
},
resolve: {
alias: {
'tingle-ui': path.join(__dirname, 'dist', 'tingle-ui.js')
}
},
externals: {
"react": {
root: 'React',
var: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react'
},
"react-dom": {
root: 'ReactDOM',
var: 'ReactDOM',
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom'
}
},
plugins: [
new webpack.DefinePlugin({
__LOCAL__: true, // 本地环境
__DEV__: true, // 日常环境
__PRO__: false // 生产环境
})
]
};