-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.js
72 lines (71 loc) · 1.94 KB
/
webpack.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
71
72
/**
* Build Components for tingle
* @author alex.mm
*
* Copyright 2014-2016, Tingle Team.
* All rights reserved.
*/
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var pkg = require('./package.json');
module.exports = {
cache: false,
entry: {
'tingle-ui': __dirname + '/src/tingle-ui.js'
},
output: {
path: __dirname + '/dist',
filename: "[name].js",
library: 'TingleUI',
libraryTarget: "umd"
//sourceMapFilename: "[name].js.map"
},
devtool: '#source-map', // 这个配置要和output.sourceMapFilename一起使用
module: {
loaders: [
{
test: /\.js$/,
// tingle以外的modules都不需要经过babel解析
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-1'],
plugins: ['add-module-exports']
}
},
{
test: /\.svg$/,
loader: 'babel?presets[]=react,presets[]=es2015,presets[]=stage-1!svg-react?attrs={style:{}}',
}
]
},
plugins: [
new webpack.DefinePlugin({
'webpack_set_version': 'VERSION = "' + pkg.version + '"',
'webpack_set_global_salt_ui': 'window.SaltUI = TingleUI'
}),
new webpack.optimize.DedupePlugin(),
],
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'
}
}
};