Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Step 1.3: Updated webpack file
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 26, 2017
1 parent 5080e07 commit 1cd690d
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions webpack.config.js
Expand Up @@ -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: {
Expand All @@ -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.