Skip to content

Commit 5cd3fff

Browse files
Upgrade build config
1 parent 77785b2 commit 5cd3fff

5 files changed

Lines changed: 10 additions & 39 deletions

File tree

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"root": true,
23
"env": {
34
"browser": true,
45
"commonjs": true,

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
node-version: 18
2323
- run: npm ci
2424
- run: npm run build
25-
- run: npm run prod
2625
- name: Archive production artifacts
2726
uses: actions/upload-artifact@v2
2827
with:

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
node-version: 18
2222
- run: npm ci
2323
- run: npm run build
24-
- run: npm run prod
2524

2625
publish-npm:
2726
needs: build
@@ -34,7 +33,6 @@ jobs:
3433
registry-url: https://registry.npmjs.org/
3534
- run: npm ci
3635
- run: npm run build
37-
- run: npm run prod
3836
- run: npm publish
3937
env:
4038
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
@@ -50,7 +48,6 @@ jobs:
5048
registry-url: https://registry.npmjs.org/
5149
- run: npm ci
5250
- run: npm run build
53-
- run: npm run prod
5451
- uses: softprops/action-gh-release@v1
5552
if: startsWith(github.ref, 'refs/tags/')
5653
with:

config/rollup.base.mjs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
import chalk from 'chalk'
22

33
// Rollup plugins
4-
import {eslint} from 'rollup-plugin-eslint'
5-
import {terser} from 'rollup-plugin-terser'
6-
import buble from '@rollup/plugin-buble'
7-
import replace from '@rollup/plugin-replace'
4+
import eslint from '@rollup/plugin-eslint'
85
import resolve from '@rollup/plugin-node-resolve'
96
import commonjs from '@rollup/plugin-commonjs'
7+
import esbuild from 'rollup-plugin-esbuild'
108
import progress from 'rollup-plugin-progress'
119

12-
switch (process.env.BUILD_ENV) {
13-
case 'DEV': {
14-
console.log(chalk.cyan('+--------------=+| DEVELOP BUILD |+=--------------+'))
15-
break
16-
}
17-
case 'CI': {
18-
console.log(chalk.green('+--------------=+| CI BUILD |+=--------------+'))
19-
break
20-
}
21-
default: {
22-
console.log(chalk.yellow('+--------------=+| NORMAL BUILD |+=--------------+'))
23-
}
24-
}
10+
const isProduction = process.env.NODE_ENV === 'production'
2511

2612
// Log build environment
2713
console.log('Build Target:', chalk.bold.green(process.env.BUILD_TARGET || 'development'))
@@ -47,19 +33,10 @@ export default {
4733
browser: true,
4834
}),
4935
commonjs(),
50-
replace({
51-
preventAssignment: true,
52-
values: {
53-
'process.env.NODE_ENV': `'${process.env.BUILD_TARGET || 'development'}'`
54-
}
55-
}),
56-
buble({
57-
transforms: {
58-
modules: false,
59-
dangerousForOf: true
60-
},
61-
objectAssign: 'Object.assign'
62-
}),
63-
(process.env.BUILD_TARGET === 'production' && terser())
36+
esbuild({
37+
target: 'es2015',
38+
sourceMap: true,
39+
minify: isProduction
40+
})
6441
]
6542
}

config/rollup.prod.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Import base config
22
import base from './rollup.base.mjs'
33

4-
if (process.env.BUILD_TARGET === 'production') base.output.file = `${base.proPath}/${base.bundle}.min.js`
5-
else base.output.file = `${base.proPath}/${base.bundle}.dev.js`
6-
7-
base.output.sourcemap = process.env.BUILD_ENV === 'DEMO' || process.env.BUILD_ENV === 'CI' ? base.output.sourcemap : false
4+
base.output.file = `${base.proPath}/${base.bundle}.min.js`
85

96
delete base.bundle
107
delete base.devPath

0 commit comments

Comments
 (0)