-
Hello, I'm trying to use the USWDS in a SvelteKit application, which by default uses Vite for CSS preprocessing. Despite several attempts and reading various bits of documentation, I haven't succeeded in getting it working yet, and I'm hoping somebody here can spot what I'm doing wrong and point me in the right direction. I keep getting an error:
My import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess({
scss: {
loadPaths: ["node_modules/@uswds/uswds/packages"],
includePaths: ["node_modules/@uswds/uswds/packages"],
verbose: true,
}
}
),
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};
export default config; My import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
css: {
preprocessorOptions: {
sass: {
renderSync: true,
verbose: true,
includePaths: ["node_modules/@uswds/uswds/packages"],
loadPaths: ["node_modules/@uswds/uswds/packages"],
}
}
}
}); As you can see, I've tried adding both the newer I've followed this USWDS documentation in creating my my /* index.scss */
// 1. Load your project's USWDS settings configuration
@forward "local-variables.scss";
// 2. Load USWDS source code
@forward 'uswds';
// 3. Load your project's custom Sass
@forward "project-styles.scss"; It's failing on step 2 when it can't locate the USWDS files inside node_modules, Yes, they are installed because running SASS directly from the command line...
...works fine and produces compiled output. I just can't figure out how to make SvelteKit/Vite do the same thing as part of its build step. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Here's how I'm doing it in a React/Vite project: https://github.com/MetroStar/comet-starter/blob/main/vite.config.ts. Definitely took some figuring out...hopefully this helps. |
Beta Was this translation helpful? Give feedback.
Here's how I'm doing it in a React/Vite project: https://github.com/MetroStar/comet-starter/blob/main/vite.config.ts. Definitely took some figuring out...hopefully this helps.