Giter Club home page Giter Club logo

es6compile's Introduction

"build": "babel src -d lib"  运行 npm run build 即可把 src 目录编译输出到 lib

npm install --save-dev babel-preset-es2015 这个是把es6进行编译
根目录创建一个名为 .babelrc 的文件,里面配置如下内容:新建一个文件名为.babelrc.(在win7下),linux则直接.babelrc

.babelrc 内容 为
{
        "presets": [
            "es2015"
        ]
    }


npm install --save-dev babel-preset-react  编译react

npm install -save-dev babel-polyfill   
Babel 默认只转换新的 JavaScript 句法(syntax),而不转换新的 API ,比如 Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise 等全局对象,以及一些定义在全局对象上的方法(比如 Object.assign)都不会转码。Babel 默认不转码的 API 非常多,详细清单可以查看 definitions.js 文件

然后,在需要使用的文件的顶部引入

    import "babel-polyfill"
node.js 中:

    require('babel-polyfill');
webpack.config.js 中:

    module.exports = {
        entry: ['babel-polyfill', './app/js']
    }
最好执行下面命令
npm install webpack-dev-server -g
npm install webpack-dev-server --save-dev

webpack-dev-server --hot --inline

es6compile's People

Contributors

mountain1210 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.