-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (31 loc) · 1.22 KB
/
index.js
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
26
27
28
29
30
31
32
33
34
35
const path = require('path');
const glob = require('glob');
const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
const cordovaAssetTree = require('corber/lib/targets/cordova/utils/cordova-assets');
function CorberWebpackPlugin () {};
CorberWebpackPlugin.prototype.apply = function(compiler) {
let context = compiler.context;
let platform = process.argv.includes('--CORBER_PLATFORM=android')? 'android' : 'ios';
let cdvAssets = cordovaAssetTree.getPaths(platform, './corber/cordova');
cdvAssets.files.forEach((file) => {
if (file === 'plugins/**') {
//need to build the tree until corber/cordova/utils/cordova-assets is upgraded
let plugins = glob.sync(path.join('./corber/cordova', cdvAssets.assetsPath, 'plugins/**/*.js'));
plugins.forEach((plugin) => {
compiler.apply(new SingleEntryPlugin(
context,
path.join(process.cwd(), plugin),
plugin
));
});
} else {
let filePath = path.join(process.cwd(), './corber/cordova', cdvAssets.assetsPath, file);
compiler.apply(new SingleEntryPlugin(
context,
filePath,
file
));
}
});
};
module.exports = CorberWebpackPlugin;