【发布时间】:2016-01-12 01:23:21
【问题描述】:
我有这个正在工作的 Babel 加载器
{ test: /\.jsx?$/, loader: 'babel', query: babelSettings, exclude: /node_modules/ },
但现在我想要一个 CoffeeScript 加载器,但我想通过 Babel 管道来获取花哨的 HMR 东西
{ test: /\.coffee$/, loader: 'babel!coffee', query: babelSettings, exclude: /node_modules/ },
但这不起作用,并导致以下错误。
错误:无法在加载器列表中定义“查询”和多个加载器
知道如何为加载器链的 Babel 部分定义查询吗?查询是一个复杂的对象,我认为我无法对其进行编码。
var babelSettings = { stage: 0 };
if (process.env.NODE_ENV !== 'production') {
babelSettings.plugins = ['react-transform'];
babelSettings.extra = {
'react-transform': {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}, {
transform: 'react-transform-catch-errors',
imports: ['react', 'redbox-react']
}]
// redbox-react is breaking the line numbers :-(
// you might want to disable it
}
};
}
【问题讨论】:
标签: javascript coffeescript webpack babeljs