-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
104 lines (102 loc) · 2.95 KB
/
webpack.config.js
File metadata and controls
104 lines (102 loc) · 2.95 KB
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
const ExtWebpackPlugin = require('@sencha/ext-webpack-plugin');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const portfinder = require('portfinder');
module.exports = async function (env) {
var browserprofile
var watchprofile
var buildenvironment = env.environment || process.env.npm_package_extbuild_defaultenvironment
if (buildenvironment == 'production') {
browserprofile = false
watchprofile = 'no'
}
else {
if (env.browser == undefined) {env.browser = 'yes'}
browserprofile = env.browser || 'yes'
watchprofile = env.watch || 'yes'
}
const isProd = buildenvironment === 'production'
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 = '' }
if (env.treeshake == undefined) {env.treeshake = 'no'}
var treeshake = env.treeshake ? env.treeshake : 'no'
var basehref = env.basehref || '/'
var mode = isProd ? 'production': 'development'
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: 'yes',
browser: browserprofile,
watch: watchprofile,
profile: buildprofile,
environment: buildenvironment,
verbose: buildverbose,
treeshake: treeshake
})
]
if (!isProd) {
plugins.push(
new webpack.HotModuleReplacementPlugin()
)
}
return {
mode: 'development',
cache: true,
devtool: isProd ? 'source-map' : 'cheap-module-source-map',
context: path.join(__dirname, './'),
entry: {
'index': './app.js'
},
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'
}
}
}
}
});
}