Babel Configuration

Babel-plugin-transform-imports

Cài đặt:

$ npm install --save-dev babel-plugin-transform-imports

Cấu hình babel.config.js:

babel.config.js
["transform-imports", {
"lodash": {
"transform": "lodash/${member}",
"preventFullImport": true
}
}]

Babel-plugin-import

Cài đặt:

$ npm install babel-plugin-import --save-dev

Cấu hình babel.config.js:

babel.config.js
plugins: [
[
"import",
{ libraryName: "antd", libraryDirectory: "es", style: "css" }
],
]

Reduce the Size Of Moment.js

Cài đặt:

$ npm install babel-plugin-import --save-dev

Cấu hình wepback.base.babel.js:

wepback.base.babel.js
plugins: [
// load `moment/locale/en-gb.js` and `moment/locale/vi.js`
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en-gb|vi/),
]