babel-plugin-scenes

1.2.4 • Public • Published

babel-plugin-scenes

Babel plugin, compile the corresponding suffix file by scene.

why babel-plugin-scenes

Put the code with different scenes in different file maintenance, such as page.js and page.en.js, and then package the corresponding files according to the scene when packaging.

Usage

npm install babel-plugin-scenes --save-dev

Via .babelrc or babel-loader.

{
  "plugins": [["scenes", options]]
}

options

Options is an object that can contain the following properties:

scene [string]

Set the application scenario, the plugin will package the file corresponding to the suffix according to this property, for example, set to:

{
  "scene": "test",
}

//index.js
import {a,b} from './component'

Will be packaged with the corresponding component.test.js, if there is no such file, it will still package the original component.js.

The js file type suffix can be omitted. Not just js files, the dependencies of other types of files can be handled.

alias [object]

Alias settings, functions the same as webpack aliases. Note the alias for the alias webpack here.

Note

Currently, the modules that can be processed by plugins can be introduced in the following ways:
The introduction mode of the import from module of ES6; (v1.0.0)
ES6's import() dynamic loading method; (v1.2.0)
require() (v1.2.0)
All of the above methods support the omitting of the word 'index'.

Need to set the babel without opening the cache. Because of the babel cache, sometimes changing the file suffix requires modifying the file code that references the suffix file to take effect.

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-scenes

Weekly Downloads

3

Version

1.2.4

License

ISC

Unpacked Size

10.1 kB

Total Files

6

Last publish

Collaborators

  • myaya