Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
special-kate committed Dec 11, 2022
2 parents d865e99 + 2814f23 commit 42ac1aa
Show file tree
Hide file tree
Showing 10 changed files with 1,633 additions and 15 deletions.
21 changes: 14 additions & 7 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import archiver from 'archiver'
import esbuild from 'esbuild'
import fs, { promises as fsPromises } from 'fs'

import fs from 'fs-extra'
import { lessLoader } from 'esbuild-plugin-less'
const outdir = 'build'

async function deleteOldDir() {
await fsPromises.rm(outdir, { recursive: true, force: true })
await fs.rm(outdir, { recursive: true, force: true })
}

async function runEsbuild() {
await esbuild.build({
entryPoints: ['src/content-script/index.mjs', 'src/background/index.mjs'],
bundle: true,
outdir: outdir,
minify: true,
loader: {
'.ttf': 'dataurl',
'.woff': 'dataurl',
'.woff2': 'dataurl',
'.less': 'css',
},
plugins: [lessLoader()],
})
}

Expand All @@ -27,10 +35,10 @@ async function zipFolder(dir) {
}

async function copyFiles(entryPoints, targetDir) {
await fsPromises.mkdir(targetDir)
await fs.mkdir(targetDir)
await Promise.all(
entryPoints.map(async (entryPoint) => {
await fsPromises.copyFile(entryPoint.src, `${targetDir}/${entryPoint.dst}`)
await fs.copy(entryPoint.src, `${targetDir}/${entryPoint.dst}`)
}),
)
}
Expand All @@ -41,9 +49,8 @@ async function build() {

const commonFiles = [
{ src: 'build/content-script/index.js', dst: 'content-script.js' },
{ src: 'build/content-script/index.css', dst: 'content-script.css' },
{ src: 'build/background/index.js', dst: 'background.js' },
{ src: 'src/github-markdown.css', dst: 'github-markdown.css' },
{ src: 'src/styles.css', dst: 'styles.css' },
{ src: 'src/logo.png', dst: 'logo.png' },
]

Expand Down
Loading

0 comments on commit 42ac1aa

Please sign in to comment.