Steal can be used to load script files from a URL, such as a Content Delivery Network (CDN).
Loading from a CDN in production
A common use case is to load a script from a CDN in production-mode only.
This example will show you how to load jQuery from NPM in development mode, but use jQuery's CDN in production.
There are two changes that need to be made for this to work:
Set the Steal config to use the CDN path for production
Modify the build script to ignore jQuery when creating production bundles
System configuration
Here is an example showing how to set the System config to load jQuery from a CDN in production.
Steal can be used to load script files from a URL, such as a Content Delivery Network (CDN).
Loading from a CDN in production
A common use case is to load a script from a CDN in production-mode only. This example will show you how to load jQuery from NPM in development mode, but use jQuery's CDN in production.
There are two changes that need to be made for this to work:
System configuration
Here is an example showing how to set the System config to load jQuery from a CDN in production.
Build script
Update the build script to ignore jQuery. This example shows how to do this with a simple build.js file.
Always Loading from a CDN
If you want to load a script from a CDN in all environments:
Load Using a <script> Tag and Configure Steal to use Loaded Version
Prevent Steal from Looking for jQuery During Build
In order for the production build to work, map jQuery to the
@empty
module so Steal knows it doesn't need to try and find it: