生成taro项目时选择less,启动后报错
georgezouq opened this issue · comments
Cannot find module '/node_modules/next/dist/compiled/sass-loader/fibers.js'
@georgezouq 我使用最新的 Taro 脚手架构建项目后,并安装该插件,但并未复现你说的问题,我需要更多的复现细节。
@SyMind 项目DEMO在这里 https://github.com/georgezouq/taro-nextjs-latest 又有了一些新的问题
- npx taro build --type nextjs --watch :页面一直在 Loading状态,打不开页面
- npx taro build --type nextjs 报错:Type error: Cannot find name 'defineAppConfig'
CLI初始化参数
CLI版本:Taro v3.5.12
另外,请问,把基于 @tarojs/components 或者 taro-ui 并使用rollup编译后的组件库,直接用于一个 NextJS 的项目中是否可行?比如给 NextJS 的项目增加一些 babel 或者 webpack配置,或者在rollup编译阶段直接将组件编译成 H5版本?
想了解下插件是怎么让 tarojs 的 components 可以用在 nextjs 项目中的
谢谢啦!
@georgezouq 你的项目中存在以下问题:
pages/index/index.tsx
中引用index.less
,受限于 Next.js 页面和组件级别样式只能使用 css module。- 同上,无法在
pages/index/index.tsx
中按需要引用 taro-ui 的 css,只能在app.ts
中引入全部样式。
插件中存在以下问题:
- 没有对 node_modules 中的
@tarojs/components
和@tarojs/taro
进行替换,一方面是没有考虑 CommonJS,另一方面是 Next.js 默认不会对 node_modules 中的依赖使用 babel 进行处理。 - 对于全局样式的处理存在问题,应当是用户自定义的全局样式引入顺序在内部组件样式之后,以便于全局样式的覆盖。
最后:
由于 taro-ui 是 Taro 生态中十分流行的 ui 组件库,插件将内部对其进行支持,目前已经发布 v2.0.9 版本,请尝试使用,若存在问题欢迎告知我。
@georgezouq 我给了你 Demo 一个 PR:georgezouq/taro-nextjs-latest#1 。