:build: chore: Switch to esbuild so I can use Alpine as a package
This commit is contained in:
parent
bfcacbf1e5
commit
633613157b
1 changed files with 28 additions and 15 deletions
43
.eleventy.js
43
.eleventy.js
|
@ -1,24 +1,37 @@
|
||||||
const {minify} = require('terser');
|
const {minify} = require('terser')
|
||||||
|
const esbuild = require('esbuild')
|
||||||
|
|
||||||
module.exports = function (eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
// Process SCSS
|
// Process SCSS
|
||||||
eleventyConfig.addPlugin(require('eleventy-sass'), {
|
eleventyConfig.addPlugin(require('eleventy-sass'), {
|
||||||
postcss: require('postcss')([
|
postcss: require('postcss')([
|
||||||
require('postcss-preset-env'),
|
require('postcss-preset-env'),
|
||||||
require('cssnano')
|
require('cssnano'),
|
||||||
])
|
]),
|
||||||
});
|
})
|
||||||
|
|
||||||
// Minify and inline JS
|
// Process JS
|
||||||
eleventyConfig.addLiquidFilter('jsMin', async function (code, callback) {
|
eleventyConfig.addTemplateFormats('js')
|
||||||
try {
|
eleventyConfig.addExtension('js', {
|
||||||
const minified = await minify(code);
|
outputFileExtension: 'js',
|
||||||
callback(null, minified.code);
|
compile: async (content, path) => {
|
||||||
} catch (e) {
|
if (path !== './src/js/main.js') {
|
||||||
console.error(`Terser error: ${e}`);
|
return
|
||||||
callback(null, code);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return {dir: {input: 'src', output: 'dist'}};
|
return async () => {
|
||||||
|
const output = await esbuild.build({
|
||||||
|
target: 'es2020',
|
||||||
|
entryPoints: [path],
|
||||||
|
minify: true,
|
||||||
|
bundle: true,
|
||||||
|
write: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
return output.outputFiles[0].text
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return {dir: {input: 'src', output: 'dist'}}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue