forked from kimai/kimai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (57 loc) · 2.12 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
// Hint: if something doesn't work as expected: yarn upgrade --latest
var Encore = require('@symfony/webpack-encore');
var webpack = require('webpack');
Encore
.setOutputPath('public/build/')
.setPublicPath('build/')
.setManifestKeyPrefix('build/')
.cleanupOutputBeforeBuild()
.addEntry('app', './assets/app.js')
.addEntry('invoice', './assets/invoice.js')
.addEntry('invoice-pdf', './assets/invoice-pdf.js')
.addEntry('chart', './assets/chart.js')
.addEntry('calendar', './assets/calendar.js')
.copyFiles({ from: './assets/images', to: 'images/[path][name].[ext]' })
.splitEntryChunks()
.configureSplitChunks(function(splitChunks) {
splitChunks.chunks = 'async';
})
// bug: empty hashes in entrypoints.json
//.enableIntegrityHashes(Encore.isProduction())
.enableSingleRuntimeChunk()
.enableVersioning(Encore.isProduction())
.enableSourceMaps(!Encore.isProduction())
.enableBuildNotifications()
.enableSassLoader(function(sassOptions) {}, {
resolveUrlLoader: false
})
// to rewrite the font url() in CSS to be relative.
// https://github.com/symfony/webpack-encore/issues/915#issuecomment-827556896
.configureFontRule(
{ type: 'javascript/auto' },
(rule) => {
rule.loader = 'file-loader';
rule.options = { outputPath: 'fonts', name: '[name].[hash:8].[ext]', publicPath: './fonts/' };
}
)
.configureImageRule(
{ type: 'javascript/auto' },
(rule) => {
rule.loader = 'file-loader';
rule.options = { outputPath: 'images', name: '[name].[hash:8].[ext]', publicPath: './images/' };
}
)
.autoProvidejQuery()
// prevent that unused moment locales will be included
.addPlugin(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/))
.configureBabel(null, {
useBuiltIns: 'usage',
corejs: 3,
})
.configureCssMinimizerPlugin((options) => {
options.minimizerOptions = {
preset: ['default', { discardComments: { removeAll: true } }],
}
})
;
module.exports = Encore.getWebpackConfig();