-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.dev.js
85 lines (79 loc) · 2.34 KB
/
webpack.dev.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
const path = require('path');
const build = require('./build');
// helper functions
const mkpath = (p) => path.resolve(__dirname, '.', p);
const SRC_PATH = mkpath('src');
const DIST_PATH = mkpath('dist');
const CONF = build.loadConf(mkpath('conf/server.json'));
module.exports = (env) => ({
mode: 'development',
target: ['web', 'es5'],
entry: {
index: path.resolve(__dirname, 'src/js/page/index')
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: CONF.distFilesUrl || '/',
libraryTarget: 'var',
library: '[name]Page',
assetModuleFilename: '[hash][ext][query]'
},
resolve: {
alias: {}, // filled in dynamically
modules: [
'node_modules',
mkpath('dist/.compiled')
],
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.jsx', '.js', '.json', '.css', '.less'],
fallback: {
'path': require.resolve('path-browserify'),
'stream': require.resolve('stream-browserify')
},
symlinks: false
},
module: {
rules: [
{
test: /\.(png|jpg|gif|svg)$/,
type: 'asset/resource'
},
{
test: /\.tsx?$/,
exclude: /(node_modules)/,
use: [
{
loader: 'babel-loader',
options: build.createBabelOptions('development')
}
]
}
]
},
stats: {
colors: true
},
optimization: {
splitChunks: {
chunks: (chunk) => chunk.name !== 'sanitize-html',
name: 'common'
},
},
devtool: 'inline-source-map',
devServer: {
allowedHosts: ['localhost', 'portal.korpus.test'],
port: (CONF.develServer || {}).port || 9000,
host: (CONF.develServer || {}).host || 'localhost',
static: {
directory: path.resolve(__dirname, 'html'),
publicPath: (CONF.develServer || {}).urlRootPath + 'dist/'
},
client: {
webSocketURL: 'ws://localhost:8081/wds-ws', // TODO configurable
},
liveReload: false
},
plugins: [
new build.ProcTranslationsPlugin(SRC_PATH, DIST_PATH, CONF)
]
});