【问题标题】:Outputting compiled babel files to the same folder level将编译好的 babel 文件输出到同级文件夹
【发布时间】:2020-10-05 14:35:54
【问题描述】:

如何将编译后的 babel 文件输出到与文件相同的级别。我目前有我的脚本来读取源文件夹并将编译后的文件输出到一个单独的文件夹中,该文件夹使用我的 package.json 中的代码保留文件夹结构

  "build:lib": "./node_modules/.bin/babel src/components/ --out-dir lib",

假设我在 src/components/Button/Button.js 中有一个 react 组件。我想在 src/components/Button/Button.minified.js 中编译缩小版

【问题讨论】:

    标签: javascript reactjs npm


    【解决方案1】:

    文件扩展名选项参考:https://babeljs.io/docs/en/babel-cli#set-file-extensions

    "build:lib": "./node_modules/.bin/babel src/components/ --out-dir src/components/ --out-file-extension .minified.js",
    

    注意:这不是缩小的,而是转译的?我没看到你在哪里使用了缩小器?

    【讨论】:

    • 啊,是的,你是对的。刚刚转译。你能推荐一个好的缩小工具吗?丑化?
    • uglify 非常标准。 terser 也不错
    猜你喜欢
    • 2018-12-29
    • 1970-01-01
    • 2017-09-24
    • 2015-01-06
    • 2020-05-13
    • 1970-01-01
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多