forked from skyrim/hlviewer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
51 lines (47 loc) · 1.24 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
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const MinifyPlugin = require('babel-minify-webpack-plugin')
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
const license = fs.readFileSync('LICENSE', 'utf8')
const isProduction = process.env.NODE_ENV === 'production'
const plugins = []
if (isProduction) {
plugins.push(new MinifyPlugin())
}
plugins.push(
new CheckerPlugin(),
new webpack.BannerPlugin({
banner: license
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version)
})
)
module.exports = {
mode: isProduction ? 'production' : 'development',
entry: './src/index.ts',
output: {
filename: isProduction ? 'hlviewer.min.js' : 'hlviewer.js',
path: path.resolve(__dirname, './dist'),
library: 'HLViewer',
libraryTarget: 'umd'
},
devtool: isProduction ? 'source-map' : 'none',
module: {
rules: [
{
test: /\.tsx?$/,
include: [path.resolve(__dirname, './src')],
use: { loader: 'awesome-typescript-loader' }
}
]
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.jsx']
},
plugins,
node: {
fs: 'empty'
}
}