-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Issue type (mark with x)
- π€ Question
- π Bug report
- π Feature request
- π€·ββοΈ Other
Version (mark with x)
- 2οΈβ£ v2.24.2
- 3οΈβ£ v3.x
Description
I have .scss file imported in react component via: import './../../css/sector.scss';
For this file i have a module sector.scss.js generated with contents like given below:
!function () {
var e = document.createElement("link");
function t() {
Liferay.Loader.define("[email protected]/css/sector.scss", ["module", "exports", "require"], (function (t, s, o) {
window;
t.exports = e
}))
}
e.setAttribute("rel", "stylesheet"), e.setAttribute("type", "text/css"), e.setAttribute("href", Liferay.ThemeDisplay.getPathContext() + "/o/com-test-web/css/sector.css"), e.onload = t, e.onerror = function () {
console.warn("Unable to load /o/com-test-web/css/sector.css. However, its .js module will still be defined to avoid breaking execution flow (expect some visual degradation)."), t()
}, document.querySelector("head").appendChild(e)
}();
It adds link element with href without any timestamp (eg. /o/com-test-web/css/sector.css), version or cache busting suffix. It makes it impossible to properly cache those kind of files via cdn.
Desired behavior:
Generated href should consist cache busting fragment: timestamp, module version or file hash.
For example: /o/com-test-web/css/sector.css?t=1686646309656
Current behavior:
Generated href consists no cache busting fragment.
What is more, Liferay server sets header to: Cache-Control: max-age=315360000, public
Combination of those two issues makes it impossible to properly cache those kind of files via cdn.
Repro instructions (if applicable):
- Create React Portlet
- Create React Component
- Import .scss file into React Component Javascript file
- Run
npm run build - See generated css module contenst: build/node/packageRunBuild/resources/css/{css file name}.css.js
- CSS Module has href without cache busting fragment
Other information (environment, versions etc):
LINUX,
com.liferay.gradle.plugins.workspace version: 3.4.27
@liferay/npm-scripts version 47.0.0
liferay-npm-bundler-loader-css-loader version: 2.24.2
Liferay version: 7.4.3.33-ga33