diff options
Diffstat (limited to 'esbuild.config.js')
| -rw-r--r-- | esbuild.config.js | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/esbuild.config.js b/esbuild.config.js deleted file mode 100644 index 88d726a..0000000 --- a/esbuild.config.js +++ /dev/null @@ -1,64 +0,0 @@ -const esbuild = require('esbuild'); -const fs = require('fs-extra'); -const path = require('path'); - -const production = process.env.NODE_ENV === 'production'; - -async function buildJS() { - await esbuild.build({ - entryPoints: ['src/js/script.js'], - bundle: true, - minify: production, - sourcemap: true, - target: 'es2020', - outfile: 'dist/bundle.js', - }); -} - -async function buildCSS() { - await esbuild.build({ - entryPoints: ['src/css/style.css'], - bundle: true, - minify: production, - sourcemap: true, - loader: { - '.css': 'css', - '.woff2': 'file', - '.png': 'file', - '.svg': 'file', - }, - outfile: 'dist/bundle.css', - }); -} - -async function copyAssets() { - await fs.copy('src/assets', 'dist', { - overwrite: true, - }); -} - -async function processHTML() { - let html = await fs.readFile('src/index.html', 'utf8'); - await fs.writeFile('dist/index.html', html); -} - -async function clean() { - await fs.remove('dist'); - await fs.ensureDir('dist'); -} - -async function build() { - try { - await clean(); - await Promise.all([ - buildJS(), - buildCSS(), - copyAssets(), - ]); - await processHTML(); - } catch (err) { - process.exit(1); - } -} - -build(); |
