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

The 'postcss-import plugin cannot parse the @import syntax in LESS styles within Vue files' #466

Open
ly-yewu opened this issue Jan 4, 2025 · 1 comment

Comments

@ly-yewu
Copy link

ly-yewu commented Jan 4, 2025

It can parse LESS variables but cannot recognize the @import syntax

error

My part configuration of rollup.config.js:

alias({
  entries: [{ find: '@', replacement: resolvePath('alias','../src') }]
}),
vue({
  css: true,
  compileTemplate: true,

}),
postcss({
  extensions: ['.css','.less'],
  plugins:[
    postcssImport({
      resolve(id){
        console.log(id)
        if(id.startsWith('@/')){
          const resolvedPath = resolvePath('../src/' + id.slice(2));
          console.log(`Resolving @ path: ${id} -> ${resolvedPath}`);
          return resolvedPath;
        }
        return resolvePath('no@',id)
      }
    })
  ],
  use:[
    ['less',{
      modifyVars: {
        hack: `true; @import (reference) "${resolvePath('../src/style/variable.less')}";`
      },
      javascriptEnabled: true,
    }]
  ],
}),
@ly-yewu
Copy link
Author

ly-yewu commented Jan 6, 2025

Why does the console.log(id) statement in resolve function not execute?

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

No branches or pull requests

1 participant