/
webpack.config.js
80 lines (70 loc) · 2.21 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
72
73
74
75
76
77
78
79
80
const Encore = require('@symfony/webpack-encore');
// @see https://symfony.com/doc/current/frontend/encore/faq.html#how-do-i-integrate-my-encore-configuration-with-my-ide
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
const path = require('path');
// Default tailwindcss build process
Encore
.setOutputPath('src/Resources/public/tailwindcss/')
.setPublicPath('/tailwindcss')
.addEntry('js/app', './assets/js/app.js')
.addStyleEntry('css/app', './assets/css/app.scss')
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild([
'**/*',
'!.gitkeep',
])
.enableSourceMaps(!Encore.isProduction())
.configureBabel(() => {
}, {
useBuiltIns: 'usage',
corejs: 3
})
.enableSassLoader(sassOptions => {
}, {
resolveUrlLoader: false
})
.enablePostCssLoader(options => {
options.postcssOptions = {
config: path.join(__dirname, 'postcss-default.config.js'),
};
})
;
if (Encore.isProduction()) {
const PurgeCssPlugin = require('purgecss-webpack-plugin');
const glob = require('glob-all');
Encore.addPlugin(new PurgeCssPlugin({
paths: glob.sync([
path.join(__dirname, 'src/Resources/views/**/*.html.twig')
]),
content: ["**/*.twig"],
defaultExtractor: (content) => {
return content.match(/[\w-/:]+(?<!:)/g) || [];
}
}))
}
const defaultConfig = Encore.getWebpackConfig();
defaultConfig.name = 'defaultConfig';
Encore.reset();
// Tailwindcss JIT compiler
Encore
.setOutputPath('src/Resources/public/tailwindcss/')
.setPublicPath('/tailwindcss')
.addEntry('js/app', './assets/js/app.js')
.addStyleEntry('css/app', './assets/css/jit.css')
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild([
'**/*',
'!.gitkeep',
])
.enableSourceMaps(!Encore.isProduction())
.enablePostCssLoader(options => {
options.postcssOptions = {
config: path.join(__dirname, 'postcss-jit.config.js'),
};
})
;
const jitConfig = Encore.getWebpackConfig();
jitConfig.name = 'jitConfig';
module.exports = [defaultConfig, jitConfig];