【发布时间】:2020-08-07 12:37:37
【问题描述】:
我有以下配置让 nextjs 处理 IE11 的 ES6 代码。
module.exports = {
poweredByHeader: false,
distDir: "ssr_build",
webpack(config) {
config.node = { fs: "empty", net: "empty", tls: "empty" }
config.plugins = config.plugins || []
config.module.rules.push({
test: /\.js$/,
include: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
[
"next/babel",
{
targets: { ie: 11 },
},
],
],
},
},
})
return config
},
}
我想知道我是否可以有条件仅在 ES6 时转译 node_modules 模块,而不是花时间转译**所有内容。救命!**
Update1.0:
我已经找到了需要 ES6 转换的 ES5 依赖项:https://github.com/obahareth/are-you-es5,为排除创建了一个正则表达式,但没有用。我会再试一次,看看是否缺少子子依赖关系。
我已经尝试过 - https://github.com/martpie/next-transpile-modules,不幸的是它需要手动插入所有 node_modules。这似乎是一个乏味的过程,并停止了它。
【问题讨论】:
标签: javascript webpack babeljs next.js