-
Notifications
You must be signed in to change notification settings - Fork 114
/
webpack.config.cjs
46 lines (43 loc) · 1.03 KB
/
webpack.config.cjs
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
const path = require('path')
const commitHash = require('child_process').execSync('git rev-parse --short HEAD').toString().trim()
const webpack = require('webpack')
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
entry: './src/index.ts',
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? 'nosources-source-map' : 'inline-source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'function-plot.js',
chunkFilename: '[name].function-plot.js',
library: 'functionPlot',
libraryExport: 'default',
libraryTarget: 'umd'
},
devServer: {
static: './site'
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensionAlias: {
'.js': ['.ts', '.js'],
'.mjs': ['.mts', '.mjs']
}
},
stats: {
errorDetails: true
},
plugins: [
new webpack.DefinePlugin({
__COMMIT_HASH__: JSON.stringify(commitHash)
})
]
}