-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requiring jit-refresh.css breaks some automated builds #3
Comments
I do see that I'm calling One solution is to just touch the file in the Dockerfile: ...
RUN touch frontend/styles/jit-refresh.css
RUN npm run esbuild
... Antoher solution is to ensure the file is We can create an esbuild plugin to touch a file: // plugins/touch_file.js
const fs = require("fs");
const createTouchFilePlugin = (filePaths) => ({
name: "touch-file",
setup(build) {
build.onStart(() => {
if (!Array.isArray(filePaths) || filePaths.length === 0) {
console.warn("No file paths provided to touch.");
return;
}
const time = new Date();
filePaths.forEach((filePath) => {
try {
fs.utimesSync(filePath, time, time);
} catch (err) {
fs.closeSync(fs.openSync(filePath, "w"));
}
console.log(`Touched file at ${filePath}`);
});
});
}
});
module.exports = createTouchFilePlugin; And add this to the esbuild config: // esbuild.config.js
const esbuildOptions = {
plugins: [
touchFilePlugin(["frontend/styles/jit-refresh.css"])
],
...
} If this makes sense, I can submit a PR to add this the automation. Or perhaps it could just live in the documentation for others who hit this problem. |
@christopher-b I think just documenting it makes sense… I'll admit I'm also confused by the Docker instructions in our docs TBH, I don't understand why Ruby isn't available when building the frontend and why it's not using the Rake task. Might be a mistake. |
Yeah, we'll need to clean that up. FYI: bridgetownrb/bridgetown#952 |
I get the appeal of the multistage build... perhaps you had it set up that way so you could use base images with the appropriate dependencies? |
The installation process for this automation creates the file
frontend/styles/jit-refresh.css
, and adds that file to.gitignore
. If a build process is being run in a CI environment, or using something like Kamal which checks out a fresh copy of the repo, thejit-refresh.css
file will not be present in that build environment, and the@import
statement referencing this file will fail. A frontend build process will complete successfully (the exit code will be zero), but an error will be emitted:Any CSS below the line
@import "jit-refresh.css";
will not be included in the build artifacts, which in this case is... all of Tailwind 😁One workaround in to include
touch frontend/styles/jit-refresh.css
in the build process, before building the frontend.I wonder if there is another way to trigger Tailwind's JIT in development that doesn't break a build in a fresh checkout of the repo.
The text was updated successfully, but these errors were encountered: