Skip to content

Commit

Permalink
fix: Change runtime builder to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Aug 15, 2023
1 parent 300e954 commit e3f6cb0
Show file tree
Hide file tree
Showing 7 changed files with 1,003 additions and 1,812 deletions.
63 changes: 63 additions & 0 deletions esbuild/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node

const {build} = require('esbuild');
const {sassPlugin} = require('esbuild-sass-plugin');
const autoprefixer = require('autoprefixer');
const postcssPresetEnv = require('postcss-preset-env');
const postcss = require('postcss');
const tsconfigJson = require('../tsconfig.json');

const {
compilerOptions: {target},
} = tsconfigJson;

const common = {
bundle: true,
sourcemap: true,
platform: 'browser',
target,
tsconfig: './tsconfig.json',
};

(async function buildCss() {
await build({
...common,
entryPoints: ['src/scss/yfm.scss'],
outfile: 'dist/css/yfm.css',
format: 'iife',
plugins: [
sassPlugin({
async transform(source) {
const {css} = await postcss([
autoprefixer({cascade: false}),
postcssPresetEnv({stage: 0}),
]).process(source, {from: undefined});

return css;
},
}),
],
});

await build({
...common,
entryPoints: ['dist/css/yfm.css'],
outfile: 'dist/css/yfm.min.css',
minify: true,
});
})();

(async function buildJs() {
await build({
...common,
entryPoints: ['src/js/index.ts'],
outfile: 'dist/js/yfm.js',
});

await build({
...common,
entryPoints: ['dist/js/yfm.js'],
outfile: 'dist/js/yfm.min.js',
minify: true,
});
})();
Loading

0 comments on commit e3f6cb0

Please sign in to comment.