Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
3 changes: 2 additions & 1 deletion designer-demo/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path from 'node:path'
import { defineConfig, mergeConfig } from 'vite'
import { defineConfig, mergeConfig, loadEnv } from 'vite'
import { getDefaultConfig } from '@opentiny/tiny-engine-vite-config'

export default defineConfig((options) => {
const extOptions = {
...loadEnv(options.mode, process.cwd(), ''),
iconDirs: [path.resolve(__dirname, './node_modules/@opentiny/tiny-engine/assets/')]
}
const defaultConfig = getDefaultConfig(options, extOptions)
Expand Down
30 changes: 12 additions & 18 deletions packages/build/vite-config/src/default-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, loadEnv } from 'vite'
import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import monacoEditorPluginCjs from 'vite-plugin-monaco-editor'
Expand All @@ -12,12 +12,7 @@ import { importmapPlugin } from './externalDeps.js'
import visualizerCjs from 'rollup-plugin-visualizer'
import { fileURLToPath } from 'node:url'
import generateComment from '@opentiny/tiny-engine-vite-plugin-meta-comments'
import {
getBaseUrlFromCli,
copyBundleDeps,
copyPreviewImportMap,
copyLocalImportMap
} from './localCdnFile/index.js'
import { getBaseUrlFromCli, copyBundleDeps, copyPreviewImportMap, copyLocalImportMap } from './localCdnFile/index.js'

const monacoEditorPlugin = monacoEditorPluginCjs.default
const nodeGlobalsPolyfillPlugin = nodeGlobalsPolyfillPluginCjs.default
Expand Down Expand Up @@ -79,7 +74,7 @@ const config = {
}
}
}),
vueJsx(),
vueJsx()
],
optimizeDeps: {
esbuildOptions: {
Expand All @@ -93,7 +88,10 @@ const config = {
//@vue/repl monaco编辑器需要
resolveFrom: 'cwd',
assets: {
from: ['./node_modules/@vue/repl/dist/assets/*'], // worker.js文件以url形式引用不会被esbuild拉起,需要手动复制
from: [
'./node_modules/@vue/repl/dist/assets/*',
'./node_modules/@opentiny/tiny-engine/node_modules/@vue/repl/dist/assets/*'
], // worker.js文件以url形式引用不会被esbuild拉起,需要手动复制
to: ['./node_modules/.vite/assets'] // 开发态,js文件被缓存在.vite/deps,请求相对路径为.vite/assets
},
watch: true
Expand All @@ -112,10 +110,9 @@ const config = {
rollupOptions: {
plugins: [nodePolyfill({ include: null })], // 使用@rollup/plugin-inject的默认值{include: null}, 即在所有代码中生效
input: {
index: path.resolve(__dirname, './index.html'),
canvas: path.resolve(__dirname, './canvas.html'),
preview: path.resolve(__dirname, './preview.html'),
previewApp: path.resolve(__dirname, './previewApp.html')
index: path.resolve(process.cwd(), './index.html'),
canvas: path.resolve(process.cwd(), './canvas.html'),
preview: path.resolve(process.cwd(), './preview.html')
},
output: {
manualChunks: (id) => {
Expand Down Expand Up @@ -143,11 +140,8 @@ const importMapVersions = {
}

export default defineConfig(({ command = 'serve', mode = 'serve' }, extOptions) => {
const {
VITE_CDN_DOMAIN = 'https://npm.onmicrosoft.cn',
VITE_LOCAL_IMPORT_MAPS,
VITE_LOCAL_BUNDLE_DEPS
} = loadEnv(mode, process.cwd(), '')
const { VITE_CDN_DOMAIN = 'https://npm.onmicrosoft.cn', VITE_LOCAL_IMPORT_MAPS, VITE_LOCAL_BUNDLE_DEPS } = extOptions

const isLocalImportMap = VITE_LOCAL_IMPORT_MAPS === 'true' // true公共依赖库使用本地打包文件,false公共依赖库使用公共CDN
const isCopyBundleDeps = VITE_LOCAL_BUNDLE_DEPS === 'true' // true bundle里的cdn依赖处理成本地依赖, false 不处理

Expand Down