Skip to content

Commit

Permalink
chore: switch to sass-embedded and remedy sass API deprecation warnin…
Browse files Browse the repository at this point in the history
…gs (#1926)

- add `sass-embedded` to catalog and use it instead of `sass`
- add workspace package `@sit-onyx/shared` for shared configs
  - add `vite.config.base.ts` file for shared Vite base config
- right now we can't use a module import because of an [open Vite
issue](vitejs/vite#5370).
  We have to use a relative import instead.
  • Loading branch information
JoCa96 authored Oct 9, 2024
1 parent 65ec48d commit 68f0b4f
Show file tree
Hide file tree
Showing 15 changed files with 458 additions and 281 deletions.
3 changes: 2 additions & 1 deletion apps/demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"vue-router": "^4.4.5"
},
"devDependencies": {
"sass": "catalog:",
"@sit-onyx/shared": "workspace:^",
"sass-embedded": "catalog:",
"vue": "catalog:"
}
}
4 changes: 2 additions & 2 deletions apps/demo-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { VITE_BASE_CONFIG } from "./node_modules/@sit-onyx/shared/vite.config.base";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
...VITE_BASE_CONFIG,
});
2 changes: 2 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
"@playwright/test": "^1.47.2",
"@sit-onyx/chartjs-plugin": "workspace:^",
"@sit-onyx/icons": "workspace:^",
"@sit-onyx/shared": "workspace:^",
"@sit-onyx/vitepress-theme": "workspace:^",
"chart.js": "^4.4.4",
"postcss": "^8.4.47",
"sass-embedded": "catalog:",
"sit-onyx": "workspace:^",
"vite": "^5.4.8",
"vitepress": "^1.4.0",
Expand Down
14 changes: 3 additions & 11 deletions apps/docs/src/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { fileURLToPath } from "node:url";
import { defineConfig, type DefaultTheme, type UserConfig } from "vitepress";
import packageJson from "../../../../packages/sit-onyx/package.json" with { type: "json" };
import viteConfig from "../../vite.config";

// https://vitepress.dev/reference/site-config
export const CONFIG = {
vite: {
resolve: {
alias: {
"~components": getFilePath("../../../../packages/sit-onyx/src/components"),
},
},
...viteConfig,
plugins: [], // don't use any of the default (vue) plugins, as it would conflict with vitepress setup
},
title: "onyx",
description: packageJson.description,
Expand Down Expand Up @@ -217,8 +214,3 @@ export const CONFIG = {
} as const satisfies UserConfig<DefaultTheme.Config>;

export default defineConfig(CONFIG);

/** Gets the given path while ensuring cross-platform and correct decoding */
function getFilePath(path: string) {
return fileURLToPath(new URL(path, import.meta.url));
}
4 changes: 2 additions & 2 deletions apps/docs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import vue from "@vitejs/plugin-vue";
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import { VITE_BASE_CONFIG } from "./node_modules/@sit-onyx/shared/vite.config.base";

// https://vitejs.dev/config
export default defineConfig({
plugins: [vue()],
...VITE_BASE_CONFIG,
resolve: {
alias: {
"~components": getFilePath("../../packages/sit-onyx/src/components"),
Expand Down
1 change: 1 addition & 0 deletions apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"sit-onyx": "workspace:^"
},
"devDependencies": {
"@sit-onyx/shared": "workspace:^",
"vue": "catalog:"
}
}
4 changes: 2 additions & 2 deletions apps/playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { VITE_BASE_CONFIG } from "./node_modules/@sit-onyx/shared/vite.config.base";

// https://vitejs.dev/config
export default defineConfig({
plugins: [vue()],
...VITE_BASE_CONFIG,
optimizeDeps: {
// needed in order for the web workers of "@vue/repl" to work
exclude: ["@vue/repl"],
Expand Down
1 change: 1 addition & 0 deletions packages/chartjs-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"sit-onyx": "workspace:^"
},
"devDependencies": {
"@sit-onyx/shared": "workspace:^",
"@vue/compiler-dom": "catalog:",
"chart.js": "catalog:",
"vue": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions packages/chartjs-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { VITE_BASE_CONFIG } from "./node_modules/@sit-onyx/shared/vite.config.base";

// https://vitejs.dev/config
export default defineConfig({
plugins: [vue()],
...VITE_BASE_CONFIG,
});
12 changes: 12 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@sit-onyx/shared",
"version": "1.0.0",
"description": "",
"private": true,
"type": "module",
"peerDependencies": {
"@vitejs/plugin-vue": "^5.1.4",
"sass-embedded": "catalog:",
"vue": "catalog:"
}
}
20 changes: 20 additions & 0 deletions packages/shared/vite.config.base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import vue from "@vitejs/plugin-vue";
import { deprecations, type Deprecation, type Options } from "sass-embedded";
import type { UserConfig } from "vite";

type ViteScssOptions = Options<"async"> & { api: "modern-compiler" };

export const VITE_BASE_CONFIG = {
plugins: [vue()],
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
// error for all warnings
fatalDeprecations: (Object.values(deprecations) as Deprecation[]).filter(
({ status }) => status !== "future",
),
} satisfies ViteScssOptions,
},
},
} satisfies UserConfig;
3 changes: 2 additions & 1 deletion packages/sit-onyx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@
"devDependencies": {
"@axe-core/playwright": "^4.10.0",
"@sit-onyx/headless": "workspace:^",
"@sit-onyx/shared": "workspace:^",
"@storybook/addon-a11y": "^8.3.5",
"@vue/compiler-dom": "catalog:",
"eslint-plugin-vue-scoped-css": "^2.8.1",
"sass": "catalog:",
"sass-embedded": "catalog:",
"vue": "catalog:",
"vue-component-type-helpers": "^2.1.6"
}
Expand Down
16 changes: 2 additions & 14 deletions packages/sit-onyx/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/// <reference types="vitest" />
import vue from "@vitejs/plugin-vue";
import { fileURLToPath, URL } from "node:url";
import { Deprecation, deprecations, Options } from "sass";
import { defineConfig } from "vite";
import { VITE_BASE_CONFIG } from "./node_modules/@sit-onyx/shared/vite.config.base";
import packageJson from "./package.json";
import { vuePluginOptions } from "./playwright.config";

type ViteScssOptions = Options<"async"> & { api: "modern-compiler" };

// https://vitejs.dev/config
export default defineConfig({
...VITE_BASE_CONFIG,
plugins: [vue(vuePluginOptions)],
build: {
lib: {
Expand All @@ -32,17 +31,6 @@ export default defineConfig({
exclude: ["src/**/*.stories.ts"],
},
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
// error for all warnings
fatalDeprecations: (Object.values(deprecations) as Deprecation[]).filter(
({ status }) => status !== "future",
),
} satisfies ViteScssOptions,
},
},
});

/** Gets the given path while ensuring cross-platform and correct decoding */
Expand Down
Loading

0 comments on commit 68f0b4f

Please sign in to comment.