This repository has been archived by the owner on Feb 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebpack.config.js
62 lines (57 loc) · 1.57 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
const path = require('path');
const webpack = require('webpack');
const StringReplacePlugin = require('string-replace-webpack-plugin');
module.exports = {
entry: './src/index.js',
mode: 'production',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: process.env.BUILD_ES ? 'index.es.js' : 'index.js',
libraryTarget: 'commonjs2',
},
optimization: {
minimize: process.env.MINIMIZE === 'true',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: [
/node_modules/,
/\test.js$/,
],
},
{
/** Workaround while waiting for https://github.com/madrobby/zepto/pull/1319 */
test: /\.js$/,
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /e.data = data/g,
replacement: function() {
return `
var dataPropDescriptor = Object.getOwnPropertyDescriptor(e, 'data')
if (!dataPropDescriptor || dataPropDescriptor.writable) {
try {
e.data = data
} catch (error) { }
}
`;
},
}
]
}),
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.RESET_APP_DATA_TIMER': JSON.stringify(''),
}),
],
externals: {
'react': 'commonjs react' // this line is just to use the React dependency of our parent-testing-project instead of using our own React.
},
};