Skip to content

Commit

Permalink
feat: using vite-plugin-style-import to import styles on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed May 3, 2021
1 parent 73469c0 commit ef5ef0b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion vant/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@vitejs/plugin-vue": "^1.2.2",
"@vue/compiler-sfc": "^3.0.11",
"less": "^4.1.1",
"vite": "^2.2.4"
"vite": "^2.2.4",
"vite-plugin-style-import": "^0.10.0"
}
}
1 change: 0 additions & 1 deletion vant/vite/src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createApp } from 'vue';
import App from './App.vue';
import 'vant/lib/index.css';

createApp(App).mount('#app');
16 changes: 14 additions & 2 deletions vant/vite/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import vue from '@vitejs/plugin-vue';
import vue from "@vitejs/plugin-vue";
import styleImport from "vite-plugin-style-import";

export default {
plugins: [vue()],
plugins: [
vue(),
styleImport({
libs: [
{
libraryName: "vant",
esModule: true,
resolveStyle: (name) => `vant/es/${name}/style`,
},
],
}),
],
};

0 comments on commit ef5ef0b

Please sign in to comment.