forked from spiermar/d3-flame-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (110 loc) · 2.94 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const path = require('path')
const {
CleanWebpackPlugin
} = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const packageFile = require('./package.json')
module.exports = [{
context: path.join(__dirname, 'src'),
entry: {
'd3-flamegraph': './flamegraph.js',
'd3-flamegraph.min': './flamegraph.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: 'flamegraph',
libraryExport: 'default',
libraryTarget: 'umd'
},
plugins: [
new CopyWebpackPlugin([{
from: 'flamegraph.css',
to: 'd3-flamegraph.css'
}])
],
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
}]
},
optimization: {
minimizer: [
new TerserPlugin({
test: /\.min\.js$/i
})
]
},
devServer: {
contentBase: [path.join(__dirname, 'examples'), path.join(__dirname, 'dist')]
}
}, {
context: path.join(__dirname, 'src'),
entry: {
'colorMapper': './colorMapper.js',
'colorMapper.min': './colorMapper.js',
'tooltip': './tooltip.js',
'tooltip.min': './tooltip.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'd3-flamegraph-[name].js',
library: ['flamegraph', '[name]'],
libraryTarget: 'umd'
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
}]
},
optimization: {
minimizer: [
new TerserPlugin({
test: /\.min\.js$/i
})
]
}
}, {
context: path.join(__dirname, 'src', 'templates', 'base'),
entry: './template.js',
output: {
path: path.resolve(__dirname, 'dist', 'templates'),
filename: 'bundle.js'
},
plugins: [
new CleanWebpackPlugin({
protectWebpackAssets: false,
cleanOnceBeforeBuildPatterns: [],
cleanAfterEveryBuildPatterns: ['bundle.js']
}),
new HtmlWebpackPlugin({
template: 'template.html',
filename: 'd3-flamegraph-base.html',
inject: 'head',
templateVersion: packageFile.version
}),
new ScriptExtHtmlWebpackPlugin({
inline: ['bundle.js']
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader']
}
]
}
}]