简体   繁体   English

Webpack SCSS Angular2

[英]Webpack SCSS Angular2

I am using the angularClass webpack starter kit. 我正在使用angularClass Webpack入门套件。 I love that I do not have to set the unit testing, what a relieve. 我爱我不必设置单元测试,这真是一种解脱。 Anyways in the webpack.common.js I added the following 无论如何,在webpack.common.js我添加了以下内容

loaders: [
        {
          test: /\.scss$/,
          exclude: /node_modules/,
          loaders: ['raw-loader', 'sass-loader'] // sass-loader not scss-loader
        }
      ], 

under module{} , please note that the loaders array was not there. module{} ,请注意, loaders数组不存在。

I am getting an error saying 我说错了

parse failed - Error in path/to/scss/file - You may need an appropriate loader to handle this file type 解析失败-路径/到/ scss /文件中的错误-您可能需要适当的加载器来处理此文件类型

I can not figure out the reason for this. 我不知道原因。 especially that I used webpack with ng1 and react and used the same loader. 特别是我将Webpack与ng1一起使用并做出反应并使用了相同的加载程序。

The same issue happened with pug as well. 哈巴狗也发生了同样的问题。 I have of course followed every stack overflow and github issue but to no avail. 我当然一直在关注每个堆栈溢出和github问题,但无济于事。

Found the solution finally. 终于找到了解决方案。 OMFNG. OMFNG。

move all the objects in the array rules to loaders 将数组rules中的所有对象移至loaders

That made the scss work, i think pug will work too like that will test and see. 这使得该scss的工作,我认为pug也可以工作一样,将测试看看。 If it does not work will update this. 如果不起作用,将对此进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM