首页 新闻 会员 周边 捐助

angular: 如何在 typscript 代码中将 less 文件 import 为字符串

0
悬赏园豆:30 [已解决问题] 浏览: 24次 解决于 2025-01-30 22:42

用下面的代码 import

import _contentStyle from './tinymce5.content.less';

build 时会报错

TS2307: Cannot find module './tinymce5.content.less' or its corresponding type declarations. [plugin angular-compiler]

用的是 angular 19,build 引擎用的是 esbuild

dudu的主页 dudu | 高人七级 | 园豆:27977
提问于:2025-01-30 21:44
< > 人人可用的开源BI工具
分享
最佳答案
0

通过 with loader 解决了

import _contentStyle from './tinymce5.content.less' with { loader: 'text' };
dudu | 高人七级 |园豆:27977 | 2025-01-30 22:42

上面的方法只能实现将 .less 文件的原始内容作为字符串赋值给 _contentStyle,less 不会被编译成 css,如何先编译成 css 再作为字符串 import 详见博问 https://q.cnblogs.com/q/151668

dudu | 园豆:27977 (高人七级) | 2025-02-03 19:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册
Top