-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Change runtime builder to esbuild
- Loading branch information
Showing
7 changed files
with
1,003 additions
and
1,812 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
})(); |
Oops, something went wrong.