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

3.0.7 样式按指令进行条件编译 在build:weapp时无效 #7410

Closed
meibin08 opened this issue Aug 21, 2020 · 3 comments · Fixed by #7450
Closed

3.0.7 样式按指令进行条件编译 在build:weapp时无效 #7410

meibin08 opened this issue Aug 21, 2020 · 3 comments · Fixed by #7450
Assignees
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@meibin08
Copy link

相关平台

微信小程序

小程序基础库: 2.12.1
使用框架: React

复现步骤

  • npm run dev:weapp 在样式表里使用条件指令,有效
.login {
    position: relative;
    @include display-flex;
    @include align-items(center);

    padding: r(30) r(15) r(10);
    /* #ifdef h5 */
    font-size: 40px;
    /* #endif */
}

如图:
image

  • npm run build:weapp指令无效、无效 ,如图:

image

期望结果

npm run build:weapp 后,专属 h5环境的样式剔除

实际结果

没有剔除 h5环境的代码

环境信息

Taro CLI 3.0.7 environment info:
    System:
      OS: macOS 10.14.5
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.16.1 - /usr/local/bin/node
      Yarn: 1.19.1 - /usr/local/bin/yarn
      npm: 6.13.4 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.0.7 => 3.0.7 
      @tarojs/mini-runner: 3.0.7 => 3.0.7 
      @tarojs/react: 3.0.7 => 3.0.7 
      @tarojs/runtime: 3.0.7 => 3.0.7 
      @tarojs/taro: 3.0.7 => 3.0.7 
      @tarojs/webpack-runner: 3.0.7 => 3.0.7 
      babel-preset-taro: 3.0.7 => 3.0.7 
      eslint-config-taro: 3.0.7 => 3.0.7 
      nervjs: ^1.5.7 => 1.5.7 
      react: 16.8.2 => 16.8.2 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 
    npmGlobalPackages:
      typescript: 3.1.1
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 21, 2020
@vdfor
Copy link
Contributor

vdfor commented Aug 21, 2020

3.x似乎没有css按条件编译了

@meibin08
Copy link
Author

3.x似乎没有css按条件编译了

那该怎么弄处理呢?请指教下?

@vdfor
Copy link
Contributor

vdfor commented Aug 25, 2020

3.x似乎没有css按条件编译了

那该怎么弄处理呢?请指教下?

大概这样可以实现

// index.js
import './index.css';
// index.h5.js
import './index.h5.css';

然后在需要的地方引入js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants