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.4 打包h5 引入html5.css报错 #11390

Closed
adajoy opened this issue Mar 4, 2022 · 4 comments
Closed

taro3.4 打包h5 引入html5.css报错 #11390

adajoy opened this issue Mar 4, 2022 · 4 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@adajoy
Copy link
Contributor

adajoy commented Mar 4, 2022

相关平台

H5

复现仓库

https://github.com/adajoy/taro-h5-build-error
浏览器版本: chrome98
使用框架: React

复现步骤

使用taro3.4初始化项目 在app.ts中import '@tarojs/taro/html5.css' 使用build:h5命令打包

期望结果

打包成功

实际结果

Module not found: Can't resolve '@tarojs/taro/html5.css'

环境信息

  Taro CLI 3.4.1 environment info:
    System:
      OS: macOS 11.2.3
      Shell: 3.3.1 - /usr/local/bin/fish
    Binaries:
      Node: 14.17.6 - /usr/local/bin/node
      Yarn: 1.22.17 - ~/.yarn/bin/yarn
      npm: 6.14.15 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.4.2 => 3.4.2 
      @tarojs/mini-runner: 3.4.2 => 3.4.2 
      @tarojs/react: 3.4.2 => 3.4.2 
      @tarojs/runtime: 3.4.2 => 3.4.2 
      @tarojs/taro: 3.4.2 => 3.4.2 
      @tarojs/webpack-runner: 3.4.2 => 3.4.2 
      babel-preset-taro: 3.4.2 => 3.4.2 
      eslint-config-taro: 3.4.2 => 3.4.2 
      react: ^17.0.0 => 17.0.2
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Mar 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

等待热心的小伙伴解决问题中..., 有一些相关的 issues 可能帮助到你!

Thank you so much!

@Chen-jj
Copy link
Contributor

Chen-jj commented Mar 12, 2022

@adajoy 使用 require 代替 import 引入咯,在 H5 不需要这个样式文件。我们改一下文档

if (process.env.TARO_ENV !== 'h5') {
  require('@tarojs/taro/html5.css')
}

@Chen-jj Chen-jj closed this as completed Mar 12, 2022
@yoyo837
Copy link
Contributor

yoyo837 commented Jun 8, 2022

image

影响了nutui按钮颜色

@yoyo837
Copy link
Contributor

yoyo837 commented Jun 8, 2022

应该是加载顺序的问题,

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

3 participants