Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Dec 11, 2022
2 parents 00f83db + 8e574e7 commit 00be6a1
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 00be6a1

Please sign in to comment.