This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
94 lines (91 loc) · 2.51 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
const path = require('path');
const isEnvProduction = process.env.NODE_ENV === 'production';
const isEnvDevelopment = process.env.NODE_ENV === 'development';
const config = target => ({
mode: isEnvProduction ? 'production' : 'development',
// Stop compilation early in production
entry: ['./index.js'],
performance: {
hints: false,
},
context: path.join(__dirname, 'src'),
devtool: isEnvProduction
? 'source-map'
: isEnvDevelopment && 'cheap-module-source-map',
module: {
rules: [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },
{
oneOf: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
// Process application JS with Babel.
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: /src/,
loader: require.resolve('babel-loader'),
options: {
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
cacheCompression: false,
compact: isEnvProduction,
},
},
// Process any JS outside the app with Babel.
{
test: /\.(js|mjs)$/,
exclude: /@babel(?:\/|\\{1,2})runtime/,
loader: require.resolve('babel-loader'),
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
],
},
resolve: {
alias: {
src: path.resolve(__dirname, 'src/'),
crossfilter: 'crossfilter2',
},
extensions: ['.css', '.js', '.jsx', '.mjs'],
},
output: {
path: path.join(__dirname, 'dist/'),
filename: `react-dc.${target}.js`,
library: {
name: target !== 'module' ? 'ReactDc' : undefined,
type: target,
},
},
experiments: {
outputModule: target === 'module',
},
optimization: {
minimize: isEnvProduction,
},
externals: {
react: {
root: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
module: 'react',
},
dc: 'dc',
},
});
// noinspection WebpackConfigHighlighting
module.exports = [config('umd'), config('module')];