-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.dist.js
102 lines (89 loc) · 2.73 KB
/
webpack.config.dist.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
97
98
99
100
101
102
const path = require('path');
const webpack = require('webpack');
const glob = require("glob");
const { CheckerPlugin } = require("awesome-typescript-loader");
const pkg = require('./package.json');
const entries = {
...glob.sync('./src/**/*.ts')
.reduce(
(entries, entry) =>
Object.assign(entries,
{ [entry.replace('./src/', '').replace('.ts', '')]: entry }),
{})
};
console.log("entries:", entries);
/*
* SplitChunksPlugin is enabled by default and replaced
* deprecated CommonsChunkPlugin. It automatically identifies modules which
* should be splitted of chunk by heuristics using module duplication count and
* module category (i. e. node_modules). And splits the chunks…
*
* It is safe to remove "splitChunks" from the generated configuration
* and was added as an educational example.
*
* https://webpack.js.org/plugins/split-chunks-plugin/
*
*/
const conf = {
mode: 'production',
// devtool: false,
// devtool: "eval",
devtool: "source-map",
// devtool: "inline-source-map",
// devtool: "eval-source-map",
// devtool: "cheap-source-map",
// devtool: "inline-cheap-source-map",
// devtool: "cheap-module-source-map",
// devtool: "cheap-eval-source-map",
// devtool: "hidden-source-map",
// devtool: "nosources-source-map",
// entry: {
// index: "./src/index.ts"
// },
entry: entries,
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
priority: -10,
test: /[\\/]node_modules[\\/]/
}
},
chunks: 'async',
minChunks: 1,
minSize: 30000,
name: true
}
},
output: {
library: pkg.name,
// libraryTarget: 'global',
libraryTarget: 'umd',
// filename: '[name].[chunkhash].js',
filename: '[name].js',
path: path.resolve(__dirname, 'dist/umd')
},
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.tsx', '.ts', '.js']
},
externals: {
'incremental-dom': 'IncrementalDOM',
'numeral': 'numeral',
'moment': 'moment'
},
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
// { test: /.(ts|tsx)?$/, loader: 'ts-loader' },
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ include: [path.resolve(__dirname, 'src')] },
{ exclude: [path.resolve(__dirname, "node_modules")] }
]
},
plugins: [
new webpack.ProgressPlugin(),
new CheckerPlugin()
]
};
module.exports = [conf];