parent
7bff0b26ab
commit
98c918fbe4
3 changed files with 732 additions and 116 deletions
|
@ -1,20 +1,48 @@
|
|||
var Encore = require('@symfony/webpack-encore');
|
||||
var tailwindcss = require('tailwindcss');
|
||||
var glob = require('glob-all');
|
||||
var path = require('path');
|
||||
var PurgecssPlugin = require('purgecss-webpack-plugin');
|
||||
|
||||
/**
|
||||
* Custom PurgeCSS Extractor
|
||||
* https://github.com/FullHuman/purgecss
|
||||
* https://github.com/FullHuman/purgecss-webpack-plugin
|
||||
*/
|
||||
class TailwindExtractor {
|
||||
static extract(content) {
|
||||
return content.match(/[A-z0-9-:\/]+/g);
|
||||
}
|
||||
}
|
||||
|
||||
Encore
|
||||
.cleanupOutputBeforeBuild()
|
||||
.setOutputPath('source/build/')
|
||||
.setPublicPath('/build')
|
||||
.cleanupOutputBeforeBuild()
|
||||
.enableLessLoader()
|
||||
.addEntry('js/site', './assets/js/main.js')
|
||||
.addStyleEntry('css/site', './assets/less/main.less')
|
||||
.enablePostCssLoader(function(options) {
|
||||
options.config = {
|
||||
path: 'config/postcss.config.js'
|
||||
path: 'postcss.config.js'
|
||||
};
|
||||
})
|
||||
.enableSourceMaps(!Encore.isProduction())
|
||||
.enableVersioning(false)
|
||||
.enableBuildNotifications()
|
||||
;
|
||||
|
||||
// PurgeCSS
|
||||
Encore.addPlugin(
|
||||
new PurgecssPlugin({
|
||||
paths: glob.sync([
|
||||
path.join(__dirname, "source/**/*.{twig,html,md}")
|
||||
]),
|
||||
extractors: [
|
||||
{
|
||||
extractor: TailwindExtractor,
|
||||
extensions: ['twig', 'html', 'md']
|
||||
}
|
||||
]
|
||||
})
|
||||
);
|
||||
|
||||
module.exports = Encore.getWebpackConfig();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue