Last active
May 11, 2018 14:39
-
-
Save rigor789/37da1274240fa1c20c1000ce2fd4ed3d to your computer and use it in GitHub Desktop.
NativeScript-Vue-Externals test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// at the top of webpack.config.js: | |
const nodeModulesPath = path.resolve(__dirname, 'node_modules') | |
externals: (context, request, callback) => { | |
if(context.startsWith(nodeModulesPath)) { | |
const module = context.replace(nodeModulesPath, '').split(path.sep).find(p => !!p) | |
try { | |
const pkg = require(path.resolve(nodeModulesPath, module, 'package.json')) | |
if(pkg.nativescript) { | |
return callback(null, 'commonjs ' + request) | |
} | |
} catch(e) { | |
// ignore | |
} | |
} | |
callback() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment