Skip to content

Commit

Permalink
Step 1.1: Add webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB authored and Dotan Simha committed Nov 22, 2016
1 parent bdca3e5 commit ac89cef
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions webpack.config.js
@@ -0,0 +1,56 @@
var camelCase = require('lodash.camelcase');
var upperFirst = require('lodash.upperfirst');

module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname + '/www/js',
filename: 'app.bundle.js'
},
externals: [
{
'angular': 'angular',
'cordova': 'cordova',
'ionic': 'ionic'
},
resolveExternals
],
target: 'web',
devtool: 'source-map',
babel: {
presets: ['es2015', 'stage-0'],
plugins: ['add-module-exports']
},
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules|www)/,
loader: 'babel'
}]
},
resolve: {
extensions: ['', '.js'],
alias: {
lib: __dirname + '/www/lib'
}
}
};

function resolveExternals(context, request, callback) {
return cordovaPlugin(request, callback) ||
callback();
}

function cordovaPlugin(request, callback) {
var match = request.match(/^cordova\/(.+)$/);
var plugin = match && match[1];

if (plugin) {
plugin = camelCase(plugin);
plugin = upperFirst(plugin);
callback(null, 'this.cordova && cordova.plugins && cordova.plugins.' + plugin);
return true;
}
}

0 comments on commit ac89cef

Please sign in to comment.