Skip to content

Instantly share code, notes, and snippets.

@Mars073
Created April 16, 2022 19:37
Show Gist options
  • Save Mars073/7a92f8c1dc6e1de98c29f154cbe0f0ae to your computer and use it in GitHub Desktop.
Save Mars073/7a92f8c1dc6e1de98c29f154cbe0f0ae to your computer and use it in GitHub Desktop.
How to use a module from a cdn in vue.js by importing it from a script tag, gist with the three.js library. Pro tip: you can install `@types/three` in devDependencies to have autocompletion
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
<script
src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"
integrity="sha512-dLxUelApnYxpLt6K2iomGngnHO83iUvZytA3YjDUCjT0HDOHKXnVYdf3hU4JjM8uEhxf9nD1/ey98U3t2vZ0qQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
</head>
<body>
<!-- ... -->
<div id="app"></div>
</body>
</html>
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
// ...
configureWebpack: {
externals: {
three: 'THREE'
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment