From 8ac93684ca5a76abd2de26ad3d09241c66b33a68 Mon Sep 17 00:00:00 2001 From: Alex Blom Date: Tue, 12 Sep 2017 15:32:39 -0400 Subject: [PATCH] init --- .gitignore | 1 + index.js | 35 ++++++++++++++++++++++++++++ package.json | 30 ++++++++++++++++++++++++ yarn.lock | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..68c82ce --- /dev/null +++ b/index.js @@ -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; diff --git a/package.json b/package.json new file mode 100644 index 0000000..a27c350 --- /dev/null +++ b/package.json @@ -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": "alex@isleofcode.com", + "url": "https://isleofcode.com" + }, + "contributors": [ + { + "name": "Aidan Nulman", + "email": "aidan@isleofcode.com", + "url": "https://isleofcode.com" + } + ], + "license": "MIT", + "devDependencies": { + "glob": "^7.1.2" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..a4855bf --- /dev/null +++ b/yarn.lock @@ -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" + +concat-map@0.0.1: + 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"