Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 网页包3,提取文本插件未解析sass加载程序IncludePath_Webpack_Bourbon_Sass Loader_Extracttextwebpackplugin - Fatal编程技术网

Webpack 网页包3,提取文本插件未解析sass加载程序IncludePath

Webpack 网页包3,提取文本插件未解析sass加载程序IncludePath,webpack,bourbon,sass-loader,extracttextwebpackplugin,Webpack,Bourbon,Sass Loader,Extracttextwebpackplugin,我在一个旧项目上使用以下设置: webpack@3.0.0 extract-text-webpack-plugin@2.1.2 我现在正在尝试一个新项目,因此已升级到: webpack@3.8.1 extract-text-webpack-plugin@3.0.1. 网页包配置是完全相同的,但现在我得到了错误 我正在使用node bourbon,我想让它在我所有的条目中都可用,而不是每次都要导入它 我有一个SCSS文件:stylesheets/tools/mixins/bourbon.SCS

我在一个旧项目上使用以下设置:

webpack@3.0.0
extract-text-webpack-plugin@2.1.2
我现在正在尝试一个新项目,因此已升级到:

webpack@3.8.1
extract-text-webpack-plugin@3.0.1.
网页包配置是完全相同的,但现在我得到了错误

我正在使用node bourbon,我想让它在我所有的条目中都可用,而不是每次都要导入它

我有一个SCSS文件:stylesheets/tools/mixins/bourbon.SCSS,它(应该)只导入bourbon:
@import'bourbon'

然后,我将使用sass资源加载程序(以及其他一些mixin)使其在所有模块中都可用(请参见下面的配置)

网页包配置:

{
测试:/\.scss$/,,
用法:ExtractTextPlugin.extract({
使用:[
...
{
加载器:“sass加载器”,
选项:{
sourceMap:true,
includePaths:require('bourbon')。includePaths
}
},
{
加载器:“sass资源加载器”,
选项:{
资源:[
“./frontend/stylesheets/settings/*.scss”,
“./frontend/stylesheets/tools/***.scss”
]
},
},
]
})
},

但是,SCSS文件中的import语句未解析为节点_模块,它试图引用自身,因此出现以下错误:

模块生成失败:
@进口“波旁威士忌”;
^
已找到@import循环:

波旁威士忌的includePaths似乎被忽略了

更新:

目前,我通过直接引用波旁威士忌来解决这一问题:
@import'~bourbon/app/assets/stylesheets/_bourbon'

虽然不理想,但它确实起到了作用


有趣的是,当我将波旁威士忌
@import'bourbon'包括在内时在未在sass资源加载程序中声明的文件中工作。也许ExtractTextPlugin没有将IncludePath从sass加载程序传递到sass资源加载程序中引用的模块。

我不是肯定的,但我相信
includePath
必须是一个数组,即使只有一个条目

还有和是官方的pagkages,所以你可能会有更好的运气,而不是
node bourbon

编辑以澄清:

您需要输入以下选项→

            options: {
              sourceMap: true,
              includePaths: [require('bourbon').includePaths]
            }

谢谢你的回复。您是对的,它需要是一个数组,但bourbon返回一个数组,这样就可以了:
module.exports={includePaths:[path.join(uu dirname,'app/assets/stylesheets')]。我现在已经找到了一个解决办法,所以不用担心。