parent
7bff0b26ab
commit
98c918fbe4
|
@ -3,11 +3,13 @@
|
||||||
"@symfony/webpack-encore": "^0.17.1",
|
"@symfony/webpack-encore": "^0.17.1",
|
||||||
"autoprefixer": "^7.2.4",
|
"autoprefixer": "^7.2.4",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
|
"glob-all": "^3.1.0",
|
||||||
"highlightjs": "^9.10.0",
|
"highlightjs": "^9.10.0",
|
||||||
"less": "^2.7.3",
|
"less": "^2.7.3",
|
||||||
"less-loader": "^4.0.5",
|
"less-loader": "^4.0.5",
|
||||||
"less-plugin-npm-import": "^2.1.0",
|
"less-plugin-npm-import": "^2.1.0",
|
||||||
"postcss-loader": "^2.0.10",
|
"postcss-loader": "^2.0.10",
|
||||||
|
"purgecss-webpack-plugin": "^0.19.0",
|
||||||
"tailwindcss": "^0.4.0",
|
"tailwindcss": "^0.4.0",
|
||||||
"webpack-notifier": "^1.5.0"
|
"webpack-notifier": "^1.5.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,48 @@
|
||||||
var Encore = require('@symfony/webpack-encore');
|
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
|
Encore
|
||||||
|
.cleanupOutputBeforeBuild()
|
||||||
.setOutputPath('source/build/')
|
.setOutputPath('source/build/')
|
||||||
.setPublicPath('/build')
|
.setPublicPath('/build')
|
||||||
.cleanupOutputBeforeBuild()
|
|
||||||
.enableLessLoader()
|
.enableLessLoader()
|
||||||
.addEntry('js/site', './assets/js/main.js')
|
.addEntry('js/site', './assets/js/main.js')
|
||||||
.addStyleEntry('css/site', './assets/less/main.less')
|
.addStyleEntry('css/site', './assets/less/main.less')
|
||||||
.enablePostCssLoader(function(options) {
|
.enablePostCssLoader(function(options) {
|
||||||
options.config = {
|
options.config = {
|
||||||
path: 'config/postcss.config.js'
|
path: 'postcss.config.js'
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.enableSourceMaps(!Encore.isProduction())
|
.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();
|
module.exports = Encore.getWebpackConfig();
|
||||||
|
|
Reference in a new issue