Permalink
Browse files

Step 1.3: Updated webpack file

  • Loading branch information...
dotansimha authored and DAB0mB committed Nov 3, 2016
1 parent 5080e07 commit 1cd690da191b4e95cc0a29c899b674db2e9dcbb8
Showing with 43 additions and 3 deletions.
  1. +43 −3 webpack.config.js
View
@@ -11,9 +11,17 @@ module.exports = {
},
devtool: process.env.IONIC_GENERATE_SOURCE_MAP ? process.env.IONIC_SOURCE_MAP_TYPE : '',
externals: [
'cordova',
resolveExternals
],
resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
modules: [path.resolve('node_modules')],
alias: {
'api': path.resolve(__dirname, 'api')
}
},
module: {
@@ -31,14 +39,46 @@ module.exports = {
},
plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin()
ionicWebpackFactory.getIonicEnvironmentPlugin(),
new webpack.ProvidePlugin({
__extends: 'typescript-extends'
})
],
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
tls: 'empty',
__dirname: true
}
};
function resolveExternals(context, request, callback) {
return meteorPackage(request, callback) ||
cordovaPlugin(request, callback) ||
callback();
}
function meteorPackage(request, callback) {
var match = request.match(/^meteor\/(.+)$/);
var pack = match && match[1];
if (pack) {
callback(null, 'window.Package && Package["' + pack + '"]');
return true;
}
}
function cordovaPlugin(request, callback) {
var match = request.match(/^cordova\/(.+)$/);
var plugin = match && match[1];
if (plugin) {
plugin = camelCase(plugin);
plugin = upperFirst(plugin);
callback(null, 'window.cordova && cordova.plugins && cordova.plugins.' + plugin);
return true;
}
}

0 comments on commit 1cd690d

Please sign in to comment.