-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.base.babel.js
96 lines (86 loc) · 2.14 KB
/
webpack.base.babel.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
import webpack from 'webpack';
import path from 'path';
import fs from 'fs';
import config from './config';
import paths from './paths';
const NODE_ENV = process.env.NODE_ENV || config.NODE_ENV || 'development';
const supportedLocales = fs.readdirSync(path.resolve(__dirname, './src/app/locales/'))
.map(localePath => localePath.split('.')[0]);
const preLoaders = config.eslint ? [{
test: /\.jsx?$/,
loader: 'eslint',
include: paths.APP,
exclude: paths.ASSETS
}] : [];
const replaceModule = ({ module, replacement }) => {
return {
apply(resolver) {
resolver.plugin('module', function (req, cb) {
if (req.request === module) {
const request = {
path: req.path,
request: replacement
};
this.doResolve('module', request, cb);
} else {
cb();
}
});
}
};
};
module.exports = {
resolve: {
root: [
paths.NODE_MODULES,
paths.APP,
paths.COMPONENTS,
paths.BASIC_COMPONENTS,
paths.CONTAINERS,
paths.DOMAIN
]
},
stats: {
children: false
},
output: {
library: 'webclient',
libraryTarget: 'var',
path: paths.BUILD,
filename: 'bundle.js'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
}),
new webpack.ContextReplacementPlugin(
/intl\/locale-data\/jsonp$/,
new RegExp('^\.\/(' + supportedLocales.join('|') + ')\.js$')
),
new webpack.ResolverPlugin([replaceModule({
module: 'react/lib/invariant',
replacement: 'invariant'
})])
],
module: {
preLoaders,
loaders: [{
test: /\.jsx?$/, // test for both js and jsx
loaders: ['babel'],
exclude: [paths.ASSETS],
include: [paths.SRC, paths.TEST, /buildo-react-components/, /react-intl-hoc/]
}, {
test: /\.json$/,
loader: 'json'
}, {
test: paths.THEME_FONTS,
loader: 'file?name=[path][name].[ext]&context=' + paths.THEME
}, {
test: /\.png|\.jpg$/,
loader: 'file?name=[path][name].[ext]'
}, {
test: paths.THEME_VARIABLES,
loader: 'sass-variable'
}]
}
};