-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
72 lines (66 loc) · 1.78 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
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
// const glob = require('glob')
const packages = require('./package.json')
const manifest = path.resolve(__dirname, "dist/manifest.json")
// let componentEntries = []
// const registeredComponents = ['Counter', 'Hello', 'Nav'].forEach(comp => {
// const filename = glob.sync(`./example/**/${comp}.tsx`)
// console.log(filename)
// componentEntries = componentEntries.concat(filename)
// })
/* eslint-disable max-len */
module.exports = [
{
name: "vendor",
// mode: "development || "production",
mode: "production",
entry: Object.keys(packages.dependencies).filter(name => name.indexOf('@types') < 0).concat(['react', 'react-dom', 'react-redux']),
output: {
path: path.resolve(__dirname, "dist"),
filename: "vendor.js",
library: "vendor_[hash]"
},
plugins: [
new webpack.DllPlugin({
name: "vendor_[hash]",
path: path.resolve(__dirname, "dist/manifest.json")
})
]
},
{
name: 'app',
mode: 'development',
dependencies: ['vendor'],
devtool: 'inline-source-map',
entry: {
app: ['./example/index.tsx', './example/Components.tsx']
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/',
chunkFilename: '[name].bundle.js',
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
plugins: [
new HtmlWebpackPlugin({
template: './example/index.html',
inject: false,
chunks: ['app'],
jsassets: [`/vendor.js`],
}),
new webpack.DllReferencePlugin({
manifest: manifest
}),
],
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' },
],
},
},
]