-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
68 lines (59 loc) · 1.85 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
'use strict';
const Encore = require('@symfony/webpack-encore');
const path = require('path');
function reconfigureEncore(Encore, name) {
Encore.reset();
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
Encore.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(true)
.setOutputPath('public/dist/' + name)
.setPublicPath('/dist/' + name)
.setManifestKeyPrefix('');
return Encore;
}
const appConfig = reconfigureEncore(Encore, 'app')
.enablePostCssLoader(options => {
options.postcssOptions = {
config: './postcss.config.js',
};
})
.configureBabel(config => {
config.plugins.push('@babel/plugin-proposal-class-properties');
})
.configureBabelPresetEnv(config => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})
.autoProvidejQuery()
.addAliases({
Vendor: path.resolve(__dirname, 'vendor'),
})
.addRule({
test: /\.svg/,
type: 'asset/source',
})
.addEntry('app','./assets/app.js')
.addEntry('nette.ajax.init', './assets/nette.ajax.init.js')
.addEntry('recaptcha', './assets/recaptcha.js')
.getWebpackConfig();
const mailConfig = reconfigureEncore(Encore, 'mail')
.setOutputPath('public/dist/mail')
.setPublicPath('/dist/mail')
.enablePostCssLoader(options => {
options.postcssOptions = {
config: './postcss-mail.config.js',
};
})
.addStyleEntry('mail', './assets/css/mail/style.css')
.copyFiles({
from: './assets/images/mail'
})
.getWebpackConfig();
appConfig.name = 'app';
mailConfig.name = 'mail';
module.exports = [appConfig, mailConfig];