zoukankan      html  css  js  c++  java
  • How to use Babel without Webpack

    How to use Babel without Webpack

    You can simply run babel through the command line:

    babel --plugins transform-react-jsx-source script.js

    Docs: https://babeljs.io/docs/plugins/transform-react-jsx-source/

    Note the three "Usages" on the page. All of them will get you what you want, none of them use webpack. The .babelrcfile can handle all your plugins/transforms and is the recommended usage. Then you just run babel

    Here is an example from Material-UI's package.json

    "build:es2015": "cross-env NODE_ENV=production babel ./src --ignore *.spec.js --out-dir ./build",

    Plugins

    Babel is a compiler (source code => output code). Like many other compilers it runs in 3 stages: parsing, transforming, and printing.

    Now, out of the box Babel doesn't do anything. It basically acts like const babel = code => code; by parsing the code and then generating the same code back out again. You will need to add plugins for Babel to do anything.

    Instead of individual plugins, you can also enable a set of plugins in a preset.

     

    Transform Plugins

    These plugins apply transformations to your code.

    Transform plugins will enable the corresponding syntax plugin so you don't have to specify both.   

  • 相关阅读:
    容器适配器之queue
    STL之deque
    STL之list
    STL之multiset
    STL之multimap
    STL之set
    string
    命名空间
    Windows Live Writer教程及代码高亮工具
    STL之vector
  • 原文地址:https://www.cnblogs.com/chucklu/p/14308168.html
Copyright © 2011-2022 走看看