-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
67 lines (61 loc) · 1.27 KB
/
webpack.config.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
import { resolve } from 'path';
import webpack from 'webpack';
import camelCase from 'lodash.camelcase';
import capitalize from 'capitalize';
import { name } from './package.json';
const { env } = process;
const {
NODE_ENV = 'development',
ANIMATED_TEST,
} = env;
const isTesting = !!ANIMATED_TEST;
const isDev = NODE_ENV === 'development';
const PROJECT_PATH = __dirname;
const inProject = (...args) => resolve(PROJECT_PATH, ...args);
const inSrc = inProject.bind(null, 'src');
const srcDir = inSrc();
export default {
output: {
library: capitalize(camelCase(name)),
libraryTarget: 'umd',
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [srcDir, inProject('test')],
loader: 'babel',
query: {
presets: [
['es2015', { modules: false }],
'stage-0',
'react',
],
plugins: [
'transform-remove-strict-mode',
],
cacheDirectory: true,
babelrc: false,
},
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
'__DEV__': isDev,
}),
],
resolve: {
modules: [srcDir, 'node_modules'],
extensions: ['.js'],
alias: {
React: 'react',
},
},
devtool: 'source-map',
externals: isTesting ? {} : {
react: 'React',
'react-dom': 'ReactDOM',
},
};