-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathwebpack.config.js
63 lines (61 loc) · 1.43 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
var webpack = require('webpack');
const hash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString().replace(/(\r\n|\n|\r)/gm, '')
module.exports = {
entry: './src/index.js',
mode: 'production',
watch: true,
devtool: process.env.DEBUG ? 'eval-source-map' : undefined,
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_DEBUG': JSON.stringify(process.env.DEBUG),
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
},
{ test: /\.(png|jpg|jpeg|gif|svg)$/,
use: ['url-loader']
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [ 'file-loader']
}
]
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
output: {
path: __dirname + '/../kong-portal-templates/workspaces/default/themes/base/assets/js',
publicPath: '/',
filename: `swagger-ui-kong-theme-${hash}.${process.env.DEBUG ? 'debug' : 'min'}.js`,
library: 'SwaggerUIKongTheme',
libraryTarget: 'umd'
},
devServer: {
contentBase: './dist'
},
optimization: process.env.DEBUG ? {
minimize: false
} : undefined
}