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

taro3如何全局注入less #9578

Closed
LiangFuzhi opened this issue Jun 21, 2021 · 7 comments
Closed

taro3如何全局注入less #9578

LiangFuzhi opened this issue Jun 21, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@LiangFuzhi
Copy link

taro3如何全局注入less

试了两种方法都没生效
options.less

@theme-color: #07c160;
webpackChain (chain, webpack) {
//方法1
      chain.module.rule('less').use('style-resource')
        .loader('style-resources-loader')
        .options({
          patterns: [
            path.resolve(__dirname, 'src/assets/styles/options.less')
          ],
          // injector: 'append'
        })

//方法2
// chain.merge({
      //   module: {
      //     rule: {
      //       less: {
      //         test: /\.less$/,
      //         use: [{
      //           loader: 'style-resources-loader',
      //           options: {
      //             patterns: [path.resolve(__dirname, './src/assets/styles/options.less')],
      //             injector: 'append'
      //           }
      //         }]
      //       }
      //     }
      //   }
      // })
}

编译报错

color: fade(@theme-color, 50);
       ^
Error evaluating function `fade`: variable @theme-color is undefined
@zhangfu-git
Copy link

@LiangFuzhi 解决了吗?

@LiangFuzhi
Copy link
Author

@LiangFuzhi 解决了吗?

转用uniapp了

@Binbiubiubiu
Copy link
Contributor

Binbiubiubiu commented Mar 20, 2022

webpackChain(chain, webpack) {
  chain.module
    .rule("less")
    .oneOf("0") // 小程序平台需要这个,h5平台这行去掉
    .use("style-resource")
    .loader("style-resources-loader")
    .options({
	    patterns: [path.resolve(__dirname, "..", "src/styles/index.less")]
	    // injector: 'append'
    });
}

@rgz665
Copy link

rgz665 commented Nov 1, 2022

@Binbiubiubiu 用了还是不行

@Binbiubiubiu
Copy link
Contributor

@LarryHangFan
Copy link

@rgz665 https://github.com/Binbiubiubiu/taro-plugin-style-resource

"@tarojs/taro": "3.6.23",没用

@ixre
Copy link

ixre commented Feb 23, 2024

@rgz665 https://github.com/Binbiubiubiu/taro-plugin-style-resource

"@tarojs/taro": "3.6.23",没用

试过可以,使用的是NutUI-v4

@Chen-jj Chen-jj closed this as completed Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants