BabelJS:找不到目录中的所有 .js 文件
BabelJS: Doesn't find all .js files in directory
Babel 没有在我的目录中找到我所有的 .js/.es6 文件。
我有这个目录结构:
src/
assets/
sample/
models.es6
scripts/
playground.es6
如果我 运行 babel src --out-dir dist --source-maps --copy-files --presets env
,它只会转译 /src/assets/sample/models.es6
而不会经过 src/scripts/playground.es6
。
我做错了什么?
期待您的回复!
您可以像下面那样做:
babel src/** --out-dir lib
更多信息在 official doc
Compile Directories
Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
如果您仍然卡住,您可以使用 gulp 或 grunt 或 webpack 来 load/transpile 来自不同位置的多个指令。
希望对您有所帮助
我发现了问题。跟Babel关系不大
src/assets/**
里面是我的 Realm 数据库 sample.realm
(https://realm.io)。该文件本身不会导致问题。但是,如果您在 MacOSX 上使用 Realm Studio 打开 sample.realm
文件,则会创建一个名为 sample.realm.note
的文件。该文件导致babel不退出transpile任务
Babel 没有在我的目录中找到我所有的 .js/.es6 文件。 我有这个目录结构:
src/
assets/
sample/
models.es6
scripts/
playground.es6
如果我 运行 babel src --out-dir dist --source-maps --copy-files --presets env
,它只会转译 /src/assets/sample/models.es6
而不会经过 src/scripts/playground.es6
。
我做错了什么?
期待您的回复!
您可以像下面那样做:
babel src/** --out-dir lib
更多信息在 official doc
Compile Directories Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
如果您仍然卡住,您可以使用 gulp 或 grunt 或 webpack 来 load/transpile 来自不同位置的多个指令。
希望对您有所帮助
我发现了问题。跟Babel关系不大
src/assets/**
里面是我的 Realm 数据库 sample.realm
(https://realm.io)。该文件本身不会导致问题。但是,如果您在 MacOSX 上使用 Realm Studio 打开 sample.realm
文件,则会创建一个名为 sample.realm.note
的文件。该文件导致babel不退出transpile任务