-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
138 lines (130 loc) · 4.84 KB
/
webpack.config.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
"use strict";
var webpack = require('webpack');
var path = require('path'), join = path.join.bind(path, __dirname);
var autoprefixer = require('autoprefixer');
var lifecycle = process.env['npm_lifecycle_event'];
var isPrepublish = lifecycle === 'prepublish' || lifecycle == 'dist' || lifecycle == 'demo';
var isKarma = process.env['NODE_ENV'] === 'test';
var isTestDist = lifecycle === 'test-dist';
var subschema =
//join('../subschema/dist/subschema-noreact.js');
//join('node_modules/subschema/dist/subschema-noreact.js');
join('..', 'subschema', 'src');
var subschemaProject = join('../', 'subschema-project');
var subschemaTest = join('../', 'subschema-test-support');
var cssStr = 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss';
module.exports = {
devtool: (isPrepublish ? '#source-map' : "#inline-source-map"),
devServer: {
contentBase: join('public'),
publicPath: '/',
port: 8082
},
externals: {
'codemirror': 'CodeMirror',
'babel-standalone': 'Babel',
/* 'react-dom-external': 'ReactDOM',
'react-external': 'React'*/
},
resolve: {
extensions: ['', '.jsx', '.js'],
alias: {
//external redirects so everything uses same react.
'fbjs': join('node_modules/fbjs'),
'React': join('node_modules/react'),
'./React': join('node_modules/react'),
'react': join('node_modules/react'),
'react-dom': join('node_modules/react-dom'),
'ReactDOM': join('node_modules/react-dom'),
'react-addons-css-transition-group': join('node_modules/react-addons-css-transition-group'),
'Subschema': subschema,
'subschema-source': join('../subschema/dist'),
'subschema-project': path.join(subschemaProject, 'src/index.js'),
'subschema-test-support': path.join(subschemaTest),
// 'subschema-test-samples':join('..', 'subschema-test-samples', 'samples.js'),
'subschema-demo': isTestDist ? join('dist/index.js') : join('src/index.js'),
'ValueManager': path.join(subschema, 'ValueManager')
}
},
stats: {
colors: true,
reasons: true
},
module: {
extensions: ['', '.jsx', '.js'],
loaders: [
{
test: /\.md$/,
loader: '!!raw!',
include: [
join('public/develop')
]
},
{
test: /\.tmpl$/,
loader: path.join(subschemaProject, 'tmpl-loader'),
include: [
path.join(subschemaProject, 'src')
]
},
{
test: /.*-setup.jsx?$/,
loader: '!!raw!',
include: [
path.join(subschemaTest, 'samples')
]
},
{
test: /\.jsx?$/,
//do this to prevent babel from translating everything.
loader: 'babel',
exclude: [
/babel/,
/babylon/,
/subschema-no-react/
],
include: [
subschemaTest,
subschema,
/subschema-injection\/src/,
path.join(subschemaProject, 'src'),
join('src'),
join('public'),
isKarma ? join('test') : join('no_such_dir')
]
},
{test: /\.(png|jpe?g|mpe?g[34]?|gif)$/, loader: 'url-loader?limit=100000'},
{test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream"},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file"},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml"},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.css$/,
loader: 'style!css!postcss'
},
{
test: /\.less$/,
loader: 'style!' + cssStr + '!less'
},
{
test: /\.lessp$/,
loader: 'style!css!postcss!less'
}]
},
postcss: [autoprefixer({
browsers: ["Android 2.3", "Android >= 4",
"Chrome >= 20", "Firefox >= 24",
"Explorer >= 8", "iOS >= 6", "Opera >= 12", "Safari >= 6"]
})],
plugins: [
new webpack.ProvidePlugin({
'Babel': 'BabelStandalone',
CodeMirror: "public/codemirror",
"window.CodeMirror": "CodeMirror"
})
]
};