Adds support for the
include() function to the Babel compiler.
Why use this plugin?
A simple way to organize and reuse code.
Sometimes a bundler (Webpack/Browserify) or a task runner (Grunt/Gulp) is just too much overhead.
npm install @aternus/babel-plugin-include
babel --plugins @aternus/babel-plugin-include main.js
include() function take an argument, a filename (
Result after compilation with Babel
include()function takes a single string as an argument. Following arguments are ignored.
- The default encoding is assumed to be
- You can use relative and absolute filenames, and change the
rootdirectory in plugin options.
You can provide an options object to modify the default behavior of the plugin.
plugins: '@aternus/babel-plugin-include' options;
The following options are available:
Specify the root directory from which all files will be included. Default is
root of the including file.
Specify the encoding for the files. The encoding option specifies which encoding to use when including files. Default is
vihanb for the original package (no longer maintained).
Released under the MIT License - see
LICENSE.md for details.