1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-23 20:02:32 +08:00

rollup-plugin-esbuild

This commit is contained in:
Kevin Levron 2021-04-27 18:45:37 +02:00
parent 49a0c1fef2
commit 3131469fc2
2 changed files with 12 additions and 27 deletions

View File

@ -8,7 +8,6 @@
},
"devDependencies": {
"@microsoft/api-extractor": "^7.14.0",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-replace": "^2.3.3",
"@types/three": "^0.127.1",
"@typescript-eslint/eslint-plugin": "^4.22.0",
@ -18,6 +17,7 @@
"@vue/eslint-config-standard": "^5.1.2",
"@vue/eslint-config-typescript": "^7.0.0",
"cannon": "^0.6.2",
"esbuild": "^0.11.15",
"eslint": "^7.7.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
@ -25,9 +25,7 @@
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^7.9.0",
"gsap": "^3.5.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-vue": "^6.0.0-beta.11",
"rollup-plugin-esbuild": "^4.1.0",
"stats.js": "0.17.0",
"three": "^0.127",
"tslib": "^2.2.0",

View File

@ -1,11 +1,6 @@
import path from 'path'
import vue from 'rollup-plugin-vue'
import typescript from 'rollup-plugin-typescript2'
// import vue from 'rollup-plugin-vue'
import esbuild from 'rollup-plugin-esbuild'
import replace from '@rollup/plugin-replace'
import { terser } from "rollup-plugin-terser"
// ensure TS checks only once for each build
let hasTSChecked = false
const input = 'src/export.ts'
@ -40,20 +35,12 @@ const cdnReplaces = {
delimiters: ['', ''],
}
function createConfig(format, output, plugins = []) {
const tsPlugin = typescript({
check: false, // !hasTSChecked,
cacheRoot: path.resolve(__dirname, 'node_modules/.tscache'),
tsconfigOverride: {
compilerOptions: {
sourceMap: false, // !hasTSChecked,
declaration: false, // !hasTSChecked,
declarationMap: false, // !hasTSChecked,
},
include: [input],
},
function createConfig(format, output, plugins = [], minify = false) {
const tsPlugin = esbuild({
sourceMap: true,
minify,
target: 'es2019',
})
hasTSChecked = true
return {
input,
@ -65,8 +52,8 @@ function createConfig(format, output, plugins = []) {
sourcemap: true,
},
plugins: [
// vue(),
tsPlugin,
vue(),
...plugins,
],
}
@ -74,8 +61,8 @@ function createConfig(format, output, plugins = []) {
export default [
createConfig('es', { file: 'build/trois.module.cdn.js' }, [replace(cdnReplaces)]),
createConfig('es', { file: 'build/trois.module.cdn.min.js' }, [replace(cdnReplaces), terser()]),
createConfig('es', { file: 'build/trois.module.cdn.min.js' }, [replace(cdnReplaces)], true),
createConfig('es', { file: 'build/trois.module.js' }),
createConfig('es', { file: 'build/trois.module.min.js' }, [terser()]),
createConfig('es', { file: 'build/trois.module.min.js' }, [], true),
createConfig('cjs', { file: 'build/trois.js' }),
]