Skip to content

Commit

Permalink
reduce bundle size caused by font
Browse files Browse the repository at this point in the history
  • Loading branch information
Haberkamp committed Nov 6, 2024
1 parent 7ddef21 commit a146df0
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-readers-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": major
---

Reduce bundle size caused by font
3 changes: 2 additions & 1 deletion examples/nuxt-app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@
</template>

<script setup lang="ts">
import "@shopware-ag/meteor-component-library/dist/style.css";
import "@shopware-ag/meteor-component-library/styles";
import "@shopware-ag/meteor-component-library/font";
import {
SwCard,
SwButton,
Expand Down
1 change: 1 addition & 0 deletions packages/component-library/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Preview } from "@storybook/vue3";
import "~/src/components/assets/scss/all.scss";
import "~/src/components/assets/scss/font.scss";
import { darkTheme, lightTheme } from "./shopwareTheme";
import { setup } from "@storybook/vue3";
import { createI18n } from "vue-i18n";
Expand Down
8 changes: 8 additions & 0 deletions packages/component-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"main": "dist/common/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"exports": {
".": {
"types": "./dist/esm/index.d.ts",
"import": "./dist/esm/index.js"
},
"./styles": "./dist/index.css",
"./font": "./dist/fonts.css"
},
"files": [
"src",
"dist"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import "fonts/inter.font";
@import "variables";
@import "typography";
@import "global.scss";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "fonts/inter.font";
3 changes: 3 additions & 0 deletions packages/component-library/src/fonts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "./components/assets/scss/font.scss";

export {};
1 change: 1 addition & 0 deletions packages/component-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import MtInset from "./components/layout/mt-inset/mt-inset.vue";
import MtThemeProvider from "./components/theme/mt-theme-provider.vue";
import TooltipDirective from "./directives/tooltip.directive";
import DeviceHelperPlugin from "./plugin/device-helper.plugin";

// Import SCSS for styling
import "./components/assets/scss/all.scss";

Expand Down
5 changes: 5 additions & 0 deletions packages/component-library/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ export default defineConfig({
formats: ["es", "cjs"],
fileName: (format, entryName) => `${{ es: "esm", cjs: "common" }[format]}/${entryName}.js`,
},
cssCodeSplit: true,
rollupOptions: {
external: ["vue"],
input: {
index: path.resolve(__dirname, "src/index.ts"),
fonts: path.resolve(__dirname, "src/fonts.ts"),
},
},
},
css: {
Expand Down

0 comments on commit a146df0

Please sign in to comment.