-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.common.js
113 lines (109 loc) · 2.52 KB
/
webpack.common.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpack = require('webpack');
const ASSET_PATH = process.env.ASSET_PATH || '';
module.exports = {
entry: {
main: ['@babel/polyfill', path.resolve(__dirname, 'public/main.js')]
},
mode: 'development',
output: {
clean: true,
path: path.resolve(__dirname, 'build/release'),
filename: '[name].[contenthash].bundle.js',
publicPath: ASSET_PATH,
},
module: {
noParse: /iconv-loader\.js/,
rules: [
{
test: /mapbox-gl-rtl-text.min.js$/,
type: 'asset/resource',
},
{
test: /\.(png|jpg|gif|svg)$/,
type: 'asset/resource',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.js$/,
exclude: /node_modules|theme\.js/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.hbs$/,
use: {
loader: 'handlebars-loader'
}
}
]
},
externals: {
'config': JSON.stringify(require(path.resolve(__dirname, 'public', 'config.json')))
},
resolve: {
fallback: {
"url": require.resolve("url/")
},
alias: {
}
},
optimization: {
moduleIds: 'deterministic',
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser'
}),
new CleanWebpackPlugin({
cleanAfterEveryBuildPatterns: [
path.resolve(__dirname, 'build/release/icon*')
]
}),
new CopyWebpackPlugin({
patterns: [
{ from: './public/config.json', to: '.' },
{ from: './public/favicon.ico', to: '.' },
]
}),
new HTMLWebpackPlugin({
template: 'public/index.hbs',
hash: true,
}),
new webpack.EnvironmentPlugin({
EUI_THEME: 'amsterdam',
}),
],
stats: {
colors: true
},
devtool: 'source-map',
devServer: {
static: {
directory: './build/release',
},
}
};