forked from opentiny/tiny-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add build step to tiny-engine package (opentiny#566)
- Loading branch information
1 parent
f530e68
commit fb41533
Showing
7 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { defineConfig } from 'vite' | ||
import path from 'path' | ||
import vue from '@vitejs/plugin-vue' | ||
import vueJsx from '@vitejs/plugin-vue-jsx' | ||
import nodeGlobalsPolyfillPluginCjs from '@esbuild-plugins/node-globals-polyfill' | ||
import nodeModulesPolyfillPluginCjs from '@esbuild-plugins/node-modules-polyfill' | ||
import nodePolyfill from 'rollup-plugin-polyfill-node' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
const nodeGlobalsPolyfillPlugin = nodeGlobalsPolyfillPluginCjs.default | ||
const nodeModulesPolyfillPlugin = nodeModulesPolyfillPluginCjs.default | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
|
||
export default defineConfig({ | ||
plugins: [vue(), vueJsx()], | ||
publicDir: false, | ||
optimizeDeps: { | ||
esbuildOptions: { | ||
plugins: [ | ||
nodeGlobalsPolyfillPlugin({ | ||
process: true, | ||
buffer: true | ||
}), | ||
nodeModulesPolyfillPlugin() | ||
] | ||
} | ||
}, | ||
build: { | ||
commonjsOptions: { | ||
transformMixedEsModules: true, | ||
exclude: ['node_modules/*monaco-editor*/**', 'node_modules/lodash-es/**', 'node_modules/@types/lodash-es/**'] | ||
}, | ||
minify: true, | ||
sourcemap: true, | ||
lib: { | ||
entry: { | ||
index: path.resolve(__dirname, 'index.js'), | ||
canvas: path.resolve(__dirname, './src/canvas/canvas.js') | ||
}, | ||
name: 'tiny-engine', | ||
fileName: (_, entryName) => `${entryName}.js`, | ||
formats: ['es'] | ||
}, | ||
rollupOptions: { | ||
plugins: [nodePolyfill({ include: null })], | ||
output: { | ||
banner: (chunk) => { | ||
if (chunk.name === 'index') { | ||
return 'import "./style.css"' | ||
} | ||
} | ||
}, | ||
external: ['vue', 'monaco-editor', 'prettier', /@opentiny\/vue.*/] | ||
} | ||
} | ||
}) |