这是我的项目结构:
Project
|-module1
| |-package.json
| |-gulpfile.babel.js
|-module2
| |-package.json
| |-gulpfile.babel.js
|-package.json
|-scripts.js
|-babel.config.js 正如您在项目根目录中看到的,我有导出某些内容的scripts.js。在阅读了项目根目录下有关Babel7 configuration here的所有信息后,我创建了包含以下内容的babel.config.js:
module.exports = {
presets: [
['@babel/env', {
targets: {
node: 'current',
firefox: '60',
chrome: '67',
safari: '11.1',
},
}],
],
};据我所知,我不需要在module1和module2中创建.babelrc,因为我在根目录中有一个babel.config.js。然而,当我在module1上运行gulp时,我发现gulp没有找到巴别塔的配置,因为我得到:
Project/module1/gulpfile.babel.js:26
import gulp from 'gulp';
^^^^
SyntaxError: Unexpected identifier我的错误在哪里?
发布于 2019-02-15 04:47:04
我找到的唯一解决方案是:我们应该使用gulpfile.js而不是gulpfile.babel.js,并手动配置babel。我的意思是:
在Project/module1/gulpfile.js中
require('@babel/register')({
configFile: './../babel.config.js',
ignore: [/node_modules/]
})
require('./tasks')在Project/module1/tasks.js中,我们将所有的吞噬任务都放入其中。
https://stackoverflow.com/questions/54610390
复制相似问题