This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/webpack.config.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-01-05 22:08:06 +00:00
var Encore = require('@symfony/webpack-encore');
2018-01-16 08:14:20 +00:00
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 {
2018-01-30 23:03:06 +00:00
static extract(content) {
return content.match(/[A-z0-9-:\/]+/g);
}
2018-01-16 08:14:20 +00:00
}
2018-01-05 22:08:06 +00:00
2018-01-30 23:03:06 +00:00
Encore.cleanupOutputBeforeBuild()
2018-01-05 22:08:06 +00:00
.setOutputPath('source/build/')
.setPublicPath('/build')
.enableLessLoader()
.addEntry('js/site', './assets/js/main.js')
.addStyleEntry('css/site', './assets/less/main.less')
.enablePostCssLoader(function(options) {
options.config = {
2018-01-16 08:14:20 +00:00
path: 'postcss.config.js'
2018-01-05 22:08:06 +00:00
};
})
2018-01-30 23:03:06 +00:00
.enableSourceMaps(!Encore.isProduction());
2018-01-05 22:08:06 +00:00
Encore.addPlugin(
new PurgecssPlugin({
paths: glob.sync([
path.join(__dirname, "output_*/**/*.html"),
]),
extractors: [
{
extractor: TailwindExtractor,
extensions: ['twig', 'html', 'md']
}
]
})
);
2018-01-16 08:14:20 +00:00
2018-01-05 22:08:06 +00:00
module.exports = Encore.getWebpackConfig();