Skip to content

Instantly share code, notes, and snippets.

@rigor789
Last active May 11, 2018 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rigor789/37da1274240fa1c20c1000ce2fd4ed3d to your computer and use it in GitHub Desktop.
Save rigor789/37da1274240fa1c20c1000ce2fd4ed3d to your computer and use it in GitHub Desktop.
NativeScript-Vue-Externals test
// 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