Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow users to provide a custom root to resolve files against #66

Merged
merged 1 commit into from
Mar 5, 2021

Conversation

ElMassimo
Copy link
Collaborator

@ElMassimo ElMassimo commented Mar 4, 2021

Description 📖

This pull request adds root as a user option.

When provided, it takes precedence over Vite's config root.

When not provided, the behavior remains unchanged, so this can be released in a patch version.

Background 📜

In projects where Vite's root is not the project root, it can be preferable for files and dirs provided in the configuration options to be resolved against the project root instead of Vite's root.

Comparison

Before

Files and dirs needed to be resolved manually:

const resolve = (file) => path.resolve(process.cwd(), file)

export default defineConfig({
  plugins: [
    WindiCSS({
      config: resolve('windi.config.ts'),
      scan: {
        dirs: ['app/views', 'app/helpers', 'app/javascript'].map(resolve),
      },
    }),
	...

After

Providing the root allows files and dirs to be resolved to be resolved against it:

export default defineConfig({
  plugins: [
    WindiCSS({
      root: process.cwd(),
      scan: {
        dirs: ['app/views', 'app/helpers', 'app/javascript'],
      },
    }),
	...

Notice that the config option is no longer necessary, as the defaults are now resolved using the provided root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants