Skip to content

Commit

Permalink
Adds config for the bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
JesuHrz committed Jan 29, 2023
1 parent c93d4b8 commit 4559482
Show file tree
Hide file tree
Showing 7 changed files with 4,289 additions and 2,388 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist/**/*.js
11 changes: 0 additions & 11 deletions .swcrc

This file was deleted.

71 changes: 71 additions & 0 deletions esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const path = require('path')
const glob = require('glob')
const esbuild = require('esbuild')
// const { aliasPath } = require('esbuild-plugin-alias-path')

const buildForESM = async () => {
const entryPoints = glob.sync(path.resolve(process.cwd(), 'src/**/*.js'))

const result = await esbuild.build({
entryPoints,
packages: 'external',
outdir: 'dist/esm',
format: 'esm'
// plugins: [
// aliasPath({
// alias: {
// 'killa/core': './src/core.js'
// }
// })
// ]
})

console.log(result)
}

const buildForCJS = async () => {
const entryPoints = glob.sync(path.resolve(process.cwd(), 'src/**/*.js'))

const result = await esbuild.build({
entryPoints,
packages: 'external',
outdir: 'dist/cjs',
format: 'cjs'
// plugins: [
// aliasPath({
// alias: {
// 'killa/core': './src/core.js'
// }
// })
// ]
})

console.log(result)
}

const buildForBrowser = async () => {
const result = await esbuild.build({
entryPoints: ['./src/index.js'],
bundle: true,
outfile: 'dist/killa.min.js',
minify: true,
globalName: 'window.killa',
format: 'iife',
target: [
'chrome58',
'edge16',
'firefox57',
'safari11'
]
})

console.log(result)
}

const init = async () => {
buildForESM()
buildForCJS()
buildForBrowser()
}

init()
Loading

0 comments on commit 4559482

Please sign in to comment.