baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.47k stars 2.53k forks source link

根目录下进行vite build编译 #8396

Open ziBLan opened 1 year ago

ziBLan commented 1 year ago

实现场景:

请简单描述你想要实现的原始场景,例如:我想要实现xxx的功能... 使用vite build命令进行编译文档和编辑器两个入口

存在的问题:

请简单描述你现在遇到的不符合预期的问题... 编译打包后的编辑器可以正常使用,但是文档的访问出现了样式问题

当前方案:

请粘贴你当前方案的完整 amis schema 代码... vite config配置如下: import {defineConfig} from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; import svgr from 'vite-plugin-svgr'; import monacoEditorPlugin from 'vite-plugin-monaco-editor'; import replace from '@rollup/plugin-replace'; import fis3 from './scripts/fis3plugin'; import markdown from './scripts/markdownPlugin'; import mockApi from './scripts/mockApiPlugin'; import transformMobileHtml from './scripts/transformMobileHtml'; //@ts-ignore import i18nPlugin from 'plugin-react-i18n'; import i18nConfig from './i18nConfig';

var I18N = process.env.I18N;

var PROXY_THEME = process.env.PROXY_THEME ? [ { find: 'amis-theme-editor/lib/renderers.css', replacement: path.resolve( __dirname, '../editor/packages/amis-theme-editor/src/renderers/style/_index.scss' ) }, { find: 'amis-theme-editor/lib', replacement: path.resolve( __dirname, '../editor/packages/amis-theme-editor/src' ) } ] : [];

// https://vitejs.dev/config/ export default defineConfig({

build: { minify: false, // 禁用压缩 rollupOptions: { input: { docs: path.resolve(dirname, 'index.html'), editor: path.resolve(dirname, 'packages/amis-editor/index.html'), }, output: { chunkFileNames: 'static/js/[name]-[hash].js', entryFileNames: "static/js/[name]-[hash].js", assetFileNames: "static/[ext]/name-[hash].[ext]" } }, }, plugins: [ I18N && i18nPlugin(i18nConfig),

fis3(),
markdown(),
mockApi(),
transformMobileHtml(),

react({
  babel: {
    parserOpts: {
      plugins: ['decorators-legacy', 'classProperties']
    }
  }
}),
svgr({
  exportAsDefault: true,
  svgrOptions: {
    svgProps: {
      className: 'icon'
    },
    prettier: false,
    dimensions: false
  }
}),
monacoEditorPlugin({}),
replace({
  __editor_i18n: !!I18N
})

].filter(n => n), optimizeDeps: { include: ['amis-formula/lib/doc'], exclude: [ 'amis-core', 'amis-formula', 'amis', 'amis-ui'], esbuildOptions: { target: 'esnext' } }, server: { host: '0.0.0.0', port: 8888 }, resolve: { alias: [ { find: 'moment/locale', replacement: 'moment/dist/locale' }, { find: 'amis-formula/lib', replacement: path.resolve(dirname, './packages/amis-formula/src') }, { find: 'amis-formula', replacement: path.resolve(dirname, './packages/amis-formula/src') }, { find: 'amis-ui/lib', replacement: path.resolve(dirname, './packages/amis-ui/src') }, { find: 'amis-ui', replacement: path.resolve(dirname, './packages/amis-ui/src') }, { find: 'amis-core', replacement: path.resolve(dirname, './packages/amis-core/src') }, { find: 'amis/lib', replacement: path.resolve(dirname, './packages/amis/src') }, { find: 'amis/schema.json', replacement: path.resolve(dirname, './packages/amis/schema.json') }, { find: 'amis', replacement: path.resolve(dirname, './packages/amis/src') }, { find: 'amis-editor', replacement: path.resolve(dirname, './packages/amis-editor/src') }, { find: 'amis-editor-core', replacement: path.resolve(dirname, './packages/amis-editor-core/src') }, { find: 'office-viewer', replacement: path.resolve(__dirname, './packages/office-viewer/src') } ].concat(PROXY_THEME) },

});

code here...
github-actions[bot] commented 1 year ago

👍 Thanks for this! 🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.