-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
104 lines (103 loc) · 3.77 KB
/
webpack.config.js
File metadata and controls
104 lines (103 loc) · 3.77 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 path = require('path')
const webpack = require('webpack')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts')
const commitHash = process.env.COMMIT_HASH || 'unknown-version'
const environment = process.env.NODE_ENV || 'development'
const isProduction = environment === 'production'
module.exports = {
entry: {
amalthea: ['./web/amalthea/index.js', './web/amalthea/styles/amalthea.scss'],
callisto: ['./web/callisto/index.js', './web/callisto/styles/callisto.scss'],
ganymede: ['./web/ganymede/index.js', './web/ganymede/styles/ganymede.scss'],
himalia: './web/himalia/index.js',
io: ['./web/io/index.js', './web/io/styles/io.scss'],
core: './web/core/styles/core.scss',
errors: './web/core/styles/errors.scss'
},
output: {
path: path.resolve(__dirname, './web/public/'),
publicPath: '/public/',
filename: 'js/[name].min.js',
clean: false
},
resolve: {
alias: {
'@actions': path.resolve(__dirname, 'web/himalia/actions'),
'@app': path.resolve(__dirname, 'web/himalia/app'),
'@components': path.resolve(__dirname, 'web/himalia/components'),
'@containers': path.resolve(__dirname, 'web/himalia/containers'),
'@core': path.resolve(__dirname, 'web/core'),
'@hooks': path.resolve(__dirname, 'web/himalia/hooks'),
'@stores': path.resolve(__dirname, 'web/himalia/stores'),
'@ui': path.resolve(__dirname, 'web/himalia/ui'),
'@utils': path.resolve(__dirname, 'web/himalia/utils'),
}
},
devtool: 'cheap-module-source-map',
plugins: [
new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[name].css'
}),
new webpack.DefinePlugin({
__COMMIT_HASH__: JSON.stringify(commitHash)
})
],
optimization: {
minimizer: [new TerserPlugin({ extractComments: false })]
},
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 200,
poll: false
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: false
}
}
]
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [
'node_modules/foundation-sites/scss',
'node_modules/normalize.scss',
'web/core/styles',
'web'
],
outputStyle: isProduction ? 'compressed' : 'expanded',
quietDeps: true,
silenceDeprecations: ['legacy-js-api', 'import', 'global-builtin', 'mixed-decls']
}
}
}
]
}
]
}
}