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: support preprocessing style options (#332) #335

Merged
merged 2 commits into from
Jun 4, 2020

Conversation

daychongyang
Copy link
Contributor

@daychongyang daychongyang commented Jun 3, 2020

Support preprocessing style options, but it requires rollup-plugin-vue to support preprocessing options (PR), Otherwise, the build task will go wrong Error: variable @preprocess-custom-color is undefined.

@yyx990803 yyx990803 merged commit 13d4fc2 into vitejs:master Jun 4, 2020
@@ -133,7 +133,8 @@ export const cssPlugin: ServerPlugin = ({ root, app, watcher, resolver }) => {
filename: resolver.requestToFile(ctx.path),
scoped: false,
modules: ctx.path.includes('.module'),
preprocessLang: ctx.path.replace(cssPreprocessLangRE, '$2') as any
preprocessLang: ctx.path.replace(cssPreprocessLangRE, '$2') as any,
preprocessOptions: ctx.config.cssPreprocessOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation is not correct.

I believe this should be like this:

const preprocessLang = ctx.path.replace(cssPreprocessLangRE, '$2') as any
// ...

const result = await compileCss(root, ctx.path, {
  id: '',
  source: css,
  filename: resolver.requestToFile(ctx.path),
  scoped: false,
  modules: ctx.path.endsWith('.module.css'),
  preprocessLang,
  preprocessOptions: ctx.config.cssPreprocessOptions[preprocessLang]
})

Otherwise you can only use one preprocessor in a project.

cssPreprocessOptions: {
modifyVars: {
'preprocess-custom-color': 'green'
}
Copy link
Contributor

@Justineo Justineo Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be:

cssPreprocessOptions: {
  less: {
    modifyVars: {
      'preprocess-custom-color': 'green'
    }
  }
}

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.

3 participants