我有一个 Angular-CLI 应用程序,我尝试引入第三方依赖项,用 Coffee Script 编写。这就是我在我的组件中所做的事情:
const CoffeeWidget = require('coffee-loader!CoffeeWidget');
我以为使用咖啡装载机会起作用。但不是真的。现在我可以阅读index.coffee
,但在我的index.coffee
我require
其他咖啡文件中。像:
Cup = require '../tools/cup.coffee'
但准备好cup.coffee
并说:You may need an appropriate loader to handle this file type.
还有其他人遇到过这个问题吗?
答案 0 :(得分:3)
由于您coffee-loader
直接使用coffee-loader
,因此webpack将在所需文件上使用加载程序。
为了让webpack在任何深度找到的任何.coffee
文件上使用module.rules
,请使用以下命令扩展webpack配置中的// Webpack 2 syntax
module.exports = {
module: {
rules: [
{
test: /\.coffee$/,
use: [ 'coffee-loader' ]
}
]
}
}
数组:
@postconstruct