2023-06-05 18:33:36 -07:00
|
|
|
const {minify} = require('terser');
|
|
|
|
|
|
|
|
module.exports = function (eleventyConfig) {
|
|
|
|
// Process SCSS
|
2023-06-04 18:53:07 -07:00
|
|
|
eleventyConfig.addPlugin(require('eleventy-sass'), {
|
|
|
|
postcss: require('postcss')([
|
|
|
|
require('postcss-preset-env'),
|
|
|
|
require('cssnano')
|
|
|
|
])
|
|
|
|
});
|
|
|
|
|
2023-06-05 18:33:36 -07:00
|
|
|
// Minify and inline JS
|
|
|
|
eleventyConfig.addLiquidFilter('jsMin', async function (code, callback) {
|
|
|
|
try {
|
|
|
|
const minified = await minify(code);
|
|
|
|
callback(null, minified.code);
|
|
|
|
} catch (e) {
|
|
|
|
console.error(`Terser error: ${e}`);
|
|
|
|
callback(null, code);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return {dir: {input: 'src', output: 'dist'}};
|
2023-06-04 16:55:36 -07:00
|
|
|
}
|