如何在不更新Adobe Animate CC的情况下更换CreateJS版本?
Got it, since you can’t update your Animate CC version or modify the publish template directly, here are practical workarounds to replace the auto-injected CreateJS script:
1. Auto-Replace the Script After Publishing
The most sustainable fix is to use a simple script to automatically swap out the old CreateJS CDN link right after you publish your project. This avoids manual edits every time.
For example, here’s a quick Node.js script you can save as replace-createjs.js in your project folder:
const fs = require('fs'); const htmlPath = './publish/index.html'; // Update this to your published HTML path const oldScript = 'https://code.createjs.com/createjs-2015.11.26.min.js'; const newScript = 'https://code.createjs.com/createjs-2023.10.3.min.js'; // Use your desired version fs.readFile(htmlPath, 'utf8', (err, data) => { if (err) { console.error('Error reading file:', err); return; } const updatedData = data.replace(oldScript, newScript); fs.writeFile(htmlPath, updatedData, 'utf8', (err) => { if (err) { console.error('Error writing file:', err); return; } console.log('CreateJS version swapped successfully!'); }); });
Run it after each publish with node replace-createjs.js, or even set it up as a post-publish hook if you use a build tool like Gulp or Webpack.
2. Manual Override (Quick Testing)
If you just need to test a new CreateJS version temporarily:
- After publishing, open the generated HTML file in a text editor.
- Find the line with
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script> - Replace the
srcvalue with your target CreateJS CDN link or a local path to the newer version file. - Save the HTML and test in your browser.
Note: This is a one-off fix—you’ll have to repeat it every time you publish.
3. "Proxy" the Old Filename with New Code
Since Animate hardcodes the old CDN filename, you can trick it into loading the new version by:
- Download the newer CreateJS minified file from the official CreateJS site.
- Rename it to
createjs-2015.11.26.min.js(match the old filename exactly). - Place this renamed file in your project’s publish directory (or a subfolder like
lib/). - Edit the published HTML to change the CDN link to a local path, e.g.,
<script src="./lib/createjs-2015.11.26.min.js"></script>(you can automate this step with the script from option 1 too).
This way, Animate’s publish process still references the old filename, but it loads your updated CreateJS code instead.
Important Note
Always test thoroughly after swapping versions! Different CreateJS releases may have breaking API changes that could break your animations or interactions. Start with small tests to ensure compatibility before rolling out the change to your full project.
内容的提问来源于stack exchange,提问作者popClingwrap

