-
Notifications
You must be signed in to change notification settings - Fork 473
feat: add tinyEngineBaseConfig as base viteconfig #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hexqi
merged 3 commits into
opentiny:refactor/develop
from
chilingling:feat/tinyEngineConfigPreset
Jun 29, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,83 +1,24 @@ | ||
| import path from 'node:path' | ||
| import { defineConfig, mergeConfig, loadEnv } from 'vite' | ||
| import { getDefaultConfig } from '@opentiny/tiny-engine-vite-config' | ||
| import { defineConfig, mergeConfig } from 'vite' | ||
| import { useTinyEngineBaseConfig } from '@opentiny/tiny-engine-vite-config' | ||
|
|
||
| export default defineConfig((options) => { | ||
| const envDir = path.resolve(process.cwd(), 'env') | ||
| const extOptions = { | ||
| ...loadEnv(options.mode, envDir, 'VITE_'), | ||
| iconDirs: [path.resolve(__dirname, './node_modules/@opentiny/tiny-engine/assets/')] | ||
| } | ||
| const defaultConfig = getDefaultConfig(options, extOptions) | ||
| export default defineConfig((configEnv) => { | ||
| const baseConfig = useTinyEngineBaseConfig({ | ||
| viteConfigEnv: configEnv, | ||
| root: __dirname, | ||
| iconDirs: [path.resolve(__dirname, './node_modules/@opentiny/tiny-engine/assets/')], | ||
| useSourceAlias: true, | ||
| envDir: './env' | ||
| }) | ||
|
|
||
| const devAlias = { | ||
| '@opentiny/tiny-engine/canvas': path.resolve(__dirname, '../packages/design-core/src/canvas/canvas.js'), | ||
| '@opentiny/tiny-engine': path.resolve(__dirname, '../packages/design-core/index.js'), | ||
| '@opentiny/tiny-engine-controller/js': path.resolve(__dirname, '../packages/controller/js'), | ||
| '@opentiny/tiny-engine-common/component': path.resolve(__dirname, '../packages/common/component'), | ||
| '@opentiny/tiny-engine-common': path.resolve(__dirname, '../packages/common/index.js'), | ||
| '@opentiny/tiny-engine-controller': path.resolve(__dirname, '../packages/controller/src/index.js'), | ||
| '@opentiny/tiny-engine-plugin-materials': path.resolve(__dirname, '../packages/plugins/materials/index.js'), | ||
| '@opentiny/tiny-engine-plugin-block': path.resolve(__dirname, '../packages/plugins/block/index.js'), | ||
| '@opentiny/tiny-engine-plugin-data': path.resolve(__dirname, '../packages/plugins/data/index.js'), | ||
| '@opentiny/tiny-engine-plugin-datasource': path.resolve(__dirname, '../packages/plugins/datasource/index.js'), | ||
| '@opentiny/tiny-engine-plugin-script': path.resolve(__dirname, '../packages/plugins/script/index.js'), | ||
| '@opentiny/tiny-engine-plugin-tree': path.resolve(__dirname, '../packages/plugins/tree/index.js'), | ||
| '@opentiny/tiny-engine-plugin-help': path.resolve(__dirname, '../packages/plugins/help/index.js'), | ||
| '@opentiny/tiny-engine-plugin-schema': path.resolve(__dirname, '../packages/plugins/schema/index.js'), | ||
| '@opentiny/tiny-engine-plugin-page': path.resolve(__dirname, '../packages/plugins/page/index.js'), | ||
| '@opentiny/tiny-engine-plugin-i18n': path.resolve(__dirname, '../packages/plugins/i18n/index.js'), | ||
| '@opentiny/tiny-engine-plugin-bridge': path.resolve(__dirname, '../packages/plugins/bridge/index.js'), | ||
| '@opentiny/tiny-engine-plugin-tutorial': path.resolve(__dirname, '../packages/plugins/tutorial/index.js'), | ||
| '@opentiny/tiny-engine-plugin-robot': path.resolve(__dirname, '../packages/plugins/robot/index.js'), | ||
| '@opentiny/tiny-engine-settings-panel': path.resolve(__dirname, '../packages/settings/panel/index.js'), | ||
| '@opentiny/tiny-engine-setting-events': path.resolve(__dirname, '../packages/settings/events/index.js'), | ||
| '@opentiny/tiny-engine-setting-props': path.resolve(__dirname, '../packages/settings/props/index.js'), | ||
| '@opentiny/tiny-engine-setting-styles': path.resolve(__dirname, '../packages/settings/styles/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-breadcrumb': path.resolve(__dirname, '../packages/toolbars/breadcrumb/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-fullscreen': path.resolve(__dirname, '../packages/toolbars/fullscreen/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-lang': path.resolve(__dirname, '../packages/toolbars/lang/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-layout': path.resolve(__dirname, '../packages/toolbars/layout/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-checkinout': path.resolve(__dirname, '../packages/toolbars/lock/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-logo': path.resolve(__dirname, '../packages/toolbars/logo/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-logout': path.resolve(__dirname, '../packages/toolbars/logout/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-media': path.resolve(__dirname, '../packages/toolbars/media/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-preview': path.resolve(__dirname, '../packages/toolbars/preview/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-generate-vue': path.resolve(__dirname, '../packages/toolbars/generate-vue/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-refresh': path.resolve(__dirname, '../packages/toolbars/refresh/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-redoundo': path.resolve(__dirname, '../packages/toolbars/redoundo/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-clean': path.resolve(__dirname, '../packages/toolbars/clean/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-save': path.resolve(__dirname, '../packages/toolbars/save/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-setting': path.resolve(__dirname, '../packages/toolbars/setting/index.js'), | ||
| '@opentiny/tiny-engine-toolbar-collaboration': path.resolve(__dirname, '../packages/toolbars/collaboration/index.js'), | ||
| '@opentiny/tiny-engine-theme-dark': path.resolve(__dirname, '../packages/theme/dark/index.less'), | ||
| '@opentiny/tiny-engine-theme-light': path.resolve(__dirname, '../packages/theme/light/index.less'), | ||
| '@opentiny/tiny-engine-svgs': path.resolve(__dirname, '../packages/svgs/index.js'), | ||
| '@opentiny/tiny-engine-http': path.resolve(__dirname, '../packages/http/src/index.js'), | ||
| '@opentiny/tiny-engine-canvas': path.resolve(__dirname, '../packages/canvas/index.js'), | ||
| '@opentiny/tiny-engine-utils': path.resolve(__dirname, '../packages/utils/src/index.js'), | ||
| '@opentiny/tiny-engine-webcomponent-core': path.resolve(__dirname, '../packages/webcomponent/src/lib.js'), | ||
| '@opentiny/tiny-engine-i18n-host': path.resolve(__dirname, '../packages/i18n/src/lib.js'), | ||
| '@opentiny/tiny-engine-builtin-component': path.resolve(__dirname, '../packages/builtinComponent/index.js'), | ||
| '@opentiny/tiny-engine-entry': path.resolve(__dirname, '../packages/entry/src/index.js'), | ||
| '@opentiny/tiny-engine-layout': path.resolve(__dirname, '../packages/layout/index.js'), | ||
| '@opentiny/tiny-engine-configurator': path.resolve(__dirname, '../packages/configurator/src/index.js'), | ||
| '@opentiny/tiny-engine-theme': ['light', 'dark'].includes(extOptions.VITE_THEME) | ||
| ? path.resolve(process.cwd(), `../packages/theme/${extOptions.VITE_THEME}/index.less`) | ||
| // ? path.resolve(process.cwd(), `./node_modules/@opentiny/tiny-engine-theme-${extOptions.VITE_THEME}/dist/style.css`) | ||
| : '' | ||
| } | ||
|
|
||
| const config = { | ||
| envDir, | ||
| const customConfig = { | ||
| envDir: './env', | ||
| publicDir: path.resolve(__dirname, './public'), | ||
| server: { | ||
| port: 8090 | ||
| }, | ||
| resolve: { | ||
| alias: devAlias | ||
| } | ||
| } | ||
| return mergeConfig(defaultConfig, config) | ||
|
|
||
| return mergeConfig(baseConfig, customConfig) | ||
| }) |
This file contains hidden or 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,27 @@ | ||
| # tiny-engine-vite-config | ||
|
|
||
| > tiny-engine 构建配置 | ||
|
|
||
| ## useTinyEngineBaseConfig | ||
|
|
||
| 基础的 TinyEngine vite 配置。用户基于 cli 创建的模板依赖该基础配置。 | ||
|
|
||
| 使用: | ||
|
|
||
| ```javascript | ||
| const baseConfig = useTinyEngineBaseConfig({ | ||
| viteConfigEnv: configEnv, | ||
| root: __dirname, | ||
| iconDirs: [path.resolve(__dirname, './node_modules/@opentiny/tiny-engine/assets/')], | ||
| useSourceAlias: true, | ||
| envDir: './env' | ||
| }) | ||
| ``` | ||
|
|
||
| 配置项说明: | ||
|
|
||
| - viteConfigEnv: defineConfig 的入参 | ||
| - root:当前项目的根目录,传入 __dirname 或者 process.cwd() | ||
| - iconDirs:icon 文件夹目录 | ||
| - useSourceAlias:是否开启TinyEngine源码级别的调试 | ||
| - envDir:env 文件夹存放的目录,默认值为项目根目录 |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| export { default as getDefaultConfig } from './src/default-config.js' | ||
| export { useTinyEngineBaseConfig } from './src/default-config.js' | ||
| export { default as metaCommentsPlugin } from '@opentiny/tiny-engine-vite-plugin-meta-comments' | ||
|
chilingling marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.