|
|
@@ -0,0 +1,54 @@
|
|
|
+// 处理按需加载
|
|
|
+
|
|
|
+import { defineConfig } from 'vite';
|
|
|
+import vue from '@vitejs/plugin-vue';
|
|
|
+import Markdown from 'vite-plugin-md';
|
|
|
+import path from 'path';
|
|
|
+import config from './package.json';
|
|
|
+// https://vitejs.dev/config/
|
|
|
+
|
|
|
+const banner = `/*!
|
|
|
+* ${config.name} v${config.version} ${new Date()}
|
|
|
+* (c) 2021 @jdf2e.
|
|
|
+* Released under the MIT License.
|
|
|
+*/`;
|
|
|
+
|
|
|
+export default defineConfig({
|
|
|
+ resolve: {
|
|
|
+ alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }]
|
|
|
+ },
|
|
|
+ css: {
|
|
|
+ preprocessorOptions: {
|
|
|
+ scss: {
|
|
|
+ // example : additionalData: `@import "./src/design/styles/variables";`
|
|
|
+ // dont need include file extend .scss
|
|
|
+ additionalData: `@import "@/styles/variables.scss";@import "@/sites/assets/styles/variables.scss";`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ plugins: [
|
|
|
+ vue({
|
|
|
+ include: [/\.vue$/, /\.md$/]
|
|
|
+ }),
|
|
|
+ Markdown()
|
|
|
+ ],
|
|
|
+ build: {
|
|
|
+ rollupOptions: {
|
|
|
+ // 请确保外部化那些你的库中不需要的依赖
|
|
|
+ external: ['vue'],
|
|
|
+ output: {
|
|
|
+ banner,
|
|
|
+ // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
|
|
|
+ globals: {
|
|
|
+ vue: 'Vue'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ lib: {
|
|
|
+ entry: 'src/nutui.ts',
|
|
|
+ name: 'nutui',
|
|
|
+ formats: ['es', 'umd']
|
|
|
+ },
|
|
|
+ emptyOutDir: false
|
|
|
+ }
|
|
|
+});
|