-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.babel.js
61 lines (56 loc) · 1.56 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
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const production = process.env.NODE_ENV === 'production';
const OUTPUT_PATH = path.resolve(__dirname, 'dist');
const entry = production ? {
main: './src/index.ts',
min: './src/index.ts',
} : {
main: './src/index.ts',
min: './src/index.ts',
dev: './src/index.ts',
};
module.exports = () => ({
mode: production ? 'production' : 'development',
devtool: production ? undefined : 'source-map',
resolve: {
mainFiles: ['index'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.[jt]sx?$/,
include: [
path.resolve(__dirname, 'src'),
],
use: {
loader: 'babel-loader',
},
},
],
},
output: {
path: OUTPUT_PATH,
filename: (chunkData) => (chunkData.chunk.name === 'main' ? 'tuktuktwo.js' : 'tuktuktwo.[name].js'),
library: 'tuktuktwo',
libraryTarget: 'umd',
},
externals: ['react', 'react-dom', 'moment-timezone'],
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: process.env.NODE_ENV === 'debug' ? 'server' : 'disabled',
}),
new ForkTsCheckerWebpackPlugin({
// Options as defined in: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/master/examples/babel-loader
typescript: {
diagnosticOptions: {
semantic: true,
syntactic: true,
},
},
}),
],
entry
});