-
Notifications
You must be signed in to change notification settings - Fork 115
/
webpack.config.js
42 lines (37 loc) · 1.06 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
const path = require('path');
const cp = require('child_process');
const Encore = require('@symfony/webpack-encore');
const postcssPresetEnv = require('postcss-preset-env');
const src = path.resolve('src');
const dest = path.resolve('theme/assets');
Encore
// sources
.addEntry('main', path.join(src, 'main.js'))
.addEntry('vendor', path.join(src, 'vendor/index.js'))
// destination
.setOutputPath(dest)
.setPublicPath('/')
// features
.enableSassLoader()
.autoProvidejQuery()
.disableSingleRuntimeChunk()
.enableSourceMaps(Encore.isDev())
.enablePostCssLoader((options) => {
options.postcssOptions = {
plugins: [postcssPresetEnv()],
};
})
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})
.configureImageRule({
filename: '[name].[hash:8][ext]',
})
.configureFontRule({
filename: '[name].[hash:8][ext]',
})
.cleanupOutputBeforeBuild([], () => {
cp.spawnSync('git', ['clean', '-xdf', dest], { stdio: 'inherit' });
});
module.exports = Encore.getWebpackConfig();