-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
92 lines (87 loc) · 2.21 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
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtWebpackPlugin = require('@sencha/ext-webpack-plugin')
const portfinder = require('portfinder')
const sourcePath = path.join(__dirname, './')
module.exports = async function (env) {
var buildprofile = env.profile || process.env.npm_package_extbuild_defaultprofile
var buildenvironment = env.environment || process.env.npm_package_extbuild_defaultenvironment
var buildverbose = env.verbose || process.env.npm_package_extbuild_defaultverbose
if (buildprofile == 'all') { buildprofile = '' }
portfinder.basePort = (env && env.port) || 1962
return portfinder.getPortPromise().then(port => {
const nodeEnv = env && env.prod ? 'production' : 'development'
const isProd = nodeEnv === 'production'
const plugins = [
new HtmlWebpackPlugin({
template: 'index.html',
hash: true
}),
new ExtWebpackPlugin({
framework: 'extjs',
port: port,
emit: true,
browser: true,
watch: 'yes',
profile: buildprofile,
environment: buildenvironment,
verbose: buildverbose
})
]
if (!isProd) {
plugins.push(
new webpack.HotModuleReplacementPlugin()
)
}
return {
mode: 'development',
cache: true,
devtool: isProd ? 'source-map' : 'cheap-module-source-map',
context: sourcePath,
entry: {
'index': [
'react-hot-loader/patch',
]
},
output: {
path: path.resolve(__dirname, './'),
filename: '[name].js'
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/
}
]
},
plugins,
devServer: {
contentBase: './',
historyApiFallback: true,
host: '0.0.0.0',
hot: false,
port,
disableHostCheck: false,
compress: isProd,
inline: !isProd,
stats: {
entrypoints: false,
assets: false,
children: false,
chunks: false,
hash: false,
modules: false,
publicPath: false,
timings: false,
version: false,
warnings: false,
colors: {
green: '[32m'
}
}
}
}
})
}