我试图从打包为节点模块的自定义库中导入样式。假设包名为@定制。我打算以以下方式从@定制包中导入一个较少的文件:
@import '@custom/styles/common.less'此状态在我添加此导入语句的文件夹中搜索'@custom/styles/common.less'。
ERROR in ./src/app/app.component.less
Module build failed:
@import "@custom/styles/common";
^
Can't resolve './@custom/styles/common.less' in '<path>\src\app'
in <path>\src\app\app.component.less (line 1, column 0)是否有一种方法来声明relative-path或module-name,以便在节点模块文件夹中进行搜索?还是我错过了一些很基本的东西?
发布于 2018-10-10 00:35:31
有两种方法可以做到这一点,如果您需要将它们与项目一起编译,那么将其包含在您的角cli中,如下所示:
"styles": [
"../node_modules/custom/styles/common.less"如果您想在项目中使用较少的文件并使用它们的变量,那么您必须将其包含在您的角-cli文件中,如下所示:
"stylePreprocessorOptions": {
"includePaths": [
"../node_modules/custom/styles"
]
},在组件样式文件中,可以包含较少的文件,如@import '../styles/<your parent less file>';。
https://stackoverflow.com/questions/52293053
复制相似问题