当我们在调试模式下运行我们的站点而不缩小脚本时,它可以工作:
var defines = [
'globals',
'templates'
];
define(defines, function(globals, templates) {
//code...
});
但是一旦代码被缩小,它就会停止工作。你知道为什么吗?
请注意,这有效:
define([
'globals',
'templates'
], function(globals, templates) {
//code...
});
我们之所以要使用数组,是因为我们想循环遍历它以将 'template' 替换为 'template.1010101010',其中 10101010101 是基于文件创建的时间戳,这样维护文件使我们能够自动文件更新时绕过缓存。
请注意,我们还有更多文件要循环。