forked from SamVerschueren/babel-engine-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (22 loc) · 701 Bytes
/
index.js
File metadata and controls
25 lines (22 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
const BabelModuleTemplate = require('./lib/babel-module-template');
class BabelEnginePlugin {
constructor(babelOptions, options) {
this._options = {
babel: Object.assign({}, babelOptions),
plugin: Object.assign({verbose: true}, options)
};
}
apply(compiler) {
if (compiler.hooks) {
compiler.hooks.compilation.tap('BabelEnginePlugin', compilation => {
new BabelModuleTemplate(compilation, this._options).apply(compilation.moduleTemplates.javascript);
});
} else {
compiler.plugin('compilation', compilation => {
compilation.moduleTemplate.apply(new BabelModuleTemplate(compilation, this._options));
});
}
}
}
module.exports = BabelEnginePlugin;