2.3.2 • Published 6 years ago

ykit-config-react v2.3.2

Weekly downloads
109
License
ISC
Repository
gitlab
Last release
6 years ago

ykit-config-react

Features

  • 编译 ES6+, JSX 代码(兼容至 IE8)
  • 通过 happypack 提升编译速度
  • 设置 react 环境变量
  • 初始脚手架

Usage

如果是新项目,在一个空的目录下执行:

$ ykit init react

会在当前目录下生成一个初始工程。

如果是已有项目,在项目中执行:

$ npm install ykit-config-react --save

然后编辑 ykit.js 引入插件:

module.exports = {
    plugins: ['react']
    // ...
};

或者如果需要添加选项,也可以采用传入对象的方式:

module.exports = {
    plugins: [{
        name: 'react',
        options: {
            // 插件选项
        }
    }]
    // ...
};

babel-polyfill

babel-polyfill 默认是没有引入的,需要根据项目需求手动引入。

功能

babel 默认只转换新的 JavaScript 句法(syntax),而不转换新的API,比如 Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise 等全局对象,以及一些定义在全局对象上的方法(比如 Object.assign )都不会转码。如果需要这些 API 则要手动引入 babel-polyfill。

引入

引入 babel-polyfill 需要在入口 js 头部,加入如下一行代码:

import 'babel-polyfill';

兼容 ie8

如果需要支持 ie8,则要指定 ie8 选项:

module.exports = {
    plugins: [{
        name: 'react',
        options: {
            ie8: true
        }
    }]
    // ...
};

如何更改配置?

该插件支持更改 babel-loader 的 testexcludequery 配置项:

module.exports = {
    plugins: [
        'qunar', {
            // 通过对象的方式引入插件,可以传入 options
            name: 'react',
            options: {
                // 更改 es6 配置
                test: /\.(js)$/, // 默认是 /\.(js|jsx)$/
                exclude: /node_modules\/(?!(MY_UI)\/).*/, // 默认是 /node_modules/
                modifyQuery: function(defaultQuery) { // 可查看和编辑 defaultQuery
                    defaultQuery.presets.push('my_preset');
                    defaultQuery.plugins.push('my_plugin');
                    return defaultQuery;
                }
            }
        }
    ],
    config: {
        // ...
    }
};

示例

查看:https://github.com/roscoe054/ykit-starter-react

4.0.0-beta.2

6 years ago

4.0.0-beta.1

6 years ago

4.0.0-beta.0

6 years ago

2.3.2

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.5-rc0

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago