Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
alexblom committed Sep 13, 2017
0 parents commit 8ac9368
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "corber-webpack-plugin",
"version": "1.0.0",
"description": "Webpack plugin to enable cordova plugins during corber livereloads",
"homepage": "https://corber.io",
"repository": {
"type": "git",
"url": "https://github.com/isleofcode/corber-webpack-plugin"
},
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": {
"name": "Alex Blom",
"email": "[email protected]",
"url": "https://isleofcode.com"
},
"contributors": [
{
"name": "Aidan Nulman",
"email": "[email protected]",
"url": "https://isleofcode.com"
}
],
"license": "MIT",
"devDependencies": {
"glob": "^7.1.2"
}
}
64 changes: 64 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"

brace-expansion@^1.1.7:
version "1.1.8"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"

glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"

inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"

minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
brace-expansion "^1.1.7"

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

0 comments on commit 8ac9368

Please sign in to comment.