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

Less-loader 5.0.0: Not working with Vue-Cli 4.2.0 #5299

Closed
gavinwyf opened this issue Mar 23, 2020 · 5 comments
Closed

Less-loader 5.0.0: Not working with Vue-Cli 4.2.0 #5299

gavinwyf opened this issue Mar 23, 2020 · 5 comments

Comments

@gavinwyf
Copy link

Version

4.2.0

Environment info

- Operating System:  MacOS 10.15.3 
- Node Version: v13.0.1
- NPM Version: 6.12.0
- webpack Version: 4.42.0
- less-loader Version: 5.0.0

Steps to reproduce

// vue.config.js
    css: {
        loaderOptions: {
            less: {
                paths: [path.resolve(__dirname, 'src/assets/styles/variables.less')],
                prependData: loaderContext => {
                    const { resourcePath, rootContext } = loaderContext;
                    const relativePath = path.relative(rootContext, resourcePath);
                    return '@import "~@/assets/styles/variables.less";';
                },
                prependData: `@import "~@/assets/styles/variables.less";`,
                data: '@import "~@/assets/styles/variables.less";',
            },
        },
    },

What is expected?

全局注入Less全局变量配置

What is actually happening?

尝试了很多种loader options, 都不生效。比如:prependData, data, paths。
globalVars 可以生效,但是不能引入所有less全局配置文件。

  1. 什么才是正确的使用方式?
  2. 是否还有其他的解决方法?
@haoqunjiang
Copy link
Member

less-loader 还没发布支持 prependData 的新版本。

@gavinwyf
Copy link
Author

less-loader 还没发布支持 prependData 的新版本。

新版本不支持,老版本为啥也不好使呢?

@haoqunjiang
Copy link
Member

webpack-contrib/less-loader#327 这个功能七天前才被实现,还没发布到 npm

@FELuocheng
Copy link

逢升级cli,尴尬...

@Aysnine
Copy link

Aysnine commented May 6, 2020

@sodatea less-loader 6x 已经发布了哦

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

4 participants