在 SS 中,我们可以合并文件,使网站运行速度更快。但是当一些文件正在更新并且没有刷新到组合文件中时,这是一个问题。我必须删除组合文件并刷新缓存以重新创建文件...是否有在更改 CSS 文件时重新创建组合文件的功能?比如检查文件的日期?
示例:
$stylesheets = array(
"$themeDir/css/HomePage.css",
"$themeDir/css/Page.css",
);
Requirements::combine_files('combinedfiles.css', $stylesheets');
最佳答案
在 dev
模式下,文件不会合并。因此,在开发过程中,当文件更改很多时,请确保以开发模式运行您的网站。
您还应该正常要求所有文件。更改代码:
$stylesheets = [
$this->themeDir() . '/css/HomePage.css',
$this->themeDir() . '/css/Page.css'
];
// require the css stylesheet normally
foreach ($stylesheets as $stylesheet) {
Requirements::css($stylesheet);
}
// combine the files. In dev-mode, this has no effect
Requirements::combine_files('combinedfiles.css', $stylesheets);
当您的网站处于实时
模式时,单个文件将被组合文件替换。
关于javascript - Silverstripe 要求组合文件 CSS 和 JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39149044/