Hi everybody,
I have built a new site with Astro 1.4.x.
I deploy the site with “npm run build” which runs “astro build”.
I have a Astro component which defines some scoped styling for only this specific component. But this style does not get loaded properly after a deployment to Netlify. If I execute a local Astro build with “npm run build” and then “npm run preview” to check it out locally, then it works, the style ordering is correctly done in the html file. But on Netlify somehow the html is not built the same way and has a wrong order of loading the styles.
My current assumption:
- The Netlify build somehow does not use the latest Astro version defined in my package.json and therefore it does not build the site correctly with the fixes given in Astro 1.4 (see Astro 1.4.0 Release | Astro).
I have also already tried to execute a deployment with “clearing the build cache”, but did not help.
I also assume that the CDN invalidation works as expected, because if I change for example some content in this index html, the changes are deployed properly but not the loading of the styles.
So currently I’m a bit confused, because locally it works, but not on Netlify.
Do you have any idea why this “style loading order” issue happens?
I have a current test branch here: https://netlify-astro-style-order-issue-test--comvation-website.netlify.app/
The latest log copy:
12:54:41 PM: Build ready to start
12:54:44 PM: build-image version: 9289b698a503f132b265bd089ab40ce1d6f9e65e (focal)
12:54:44 PM: build-image tag: v4.12.0
12:54:44 PM: buildbot version: 8004afba0d79c2913deefb1ea0ee8f3ed710b828
12:54:44 PM: Building without cache
12:54:44 PM: Starting to prepare the repo for build
12:54:44 PM: No cached dependencies found. Cloning fresh repo
12:54:44 PM: git clone git@bitbucket.org:comvation/comvation.com-website
12:55:01 PM: Preparing Git Reference refs/heads/netlify-astro-style-order-issue-test
12:55:04 PM: Parsing package.json dependencies
12:55:05 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'frontend/dist' versus 'dist' in the Netlify UI
12:55:05 PM: Starting build script
12:55:05 PM: Installing dependencies
12:55:05 PM: Python version set to 2.7
12:55:05 PM: Attempting node version 'lts/*' from .nvmrc
12:55:05 PM: v16.17.1 is already installed.
12:55:05 PM: Now using node v16.17.1 (npm v8.15.0)
12:55:05 PM: Started restoring cached build plugins
12:55:05 PM: Finished restoring cached build plugins
12:55:06 PM: Attempting ruby version 2.7.2, read from environment
12:55:06 PM: Using ruby version 2.7.2
12:55:06 PM: Using PHP version 8.0
12:55:07 PM: No npm workspaces detected
12:55:07 PM: Started restoring cached node modules
12:55:07 PM: Finished restoring cached node modules
12:55:07 PM: Installing NPM modules using NPM version 8.15.0
12:55:07 PM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
12:55:07 PM: npm WARN config location in the cache, and they are managed by
12:55:07 PM: npm WARN config [`cacache`](http://npm.im/cacache).
12:55:07 PM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
12:55:07 PM: npm WARN config location in the cache, and they are managed by
12:55:07 PM: npm WARN config [`cacache`](http://npm.im/cacache).
12:55:12 PM: added 519 packages, and audited 520 packages in 5s
12:55:12 PM: 209 packages are looking for funding
12:55:12 PM: run `npm fund` for details
12:55:12 PM: found 0 vulnerabilities
12:55:12 PM: NPM modules installed
12:55:12 PM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
12:55:12 PM: npm WARN config location in the cache, and they are managed by
12:55:12 PM: npm WARN config [`cacache`](http://npm.im/cacache).
12:55:12 PM: Started restoring cached go cache
12:55:12 PM: Finished restoring cached go cache
12:55:12 PM: Installing Go version 1.16.5 (requested 1.16.5)
12:55:16 PM: unset GOOS;
12:55:16 PM: unset GOARCH;
12:55:16 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
12:55:16 PM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
12:55:16 PM: go version >&2;
12:55:16 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
12:55:16 PM: go version go1.16.5 linux/amd64
12:55:16 PM: Installing missing commands
12:55:16 PM: Verify run directory
12:55:17 PM:
12:55:17 PM: ────────────────────────────────────────────────────────────────
12:55:17 PM: Netlify Build
12:55:17 PM: ────────────────────────────────────────────────────────────────
12:55:17 PM:
12:55:17 PM: ❯ Version
12:55:17 PM: @netlify/build 27.20.1
12:55:17 PM:
12:55:17 PM: ❯ Flags
12:55:17 PM: baseRelDir: true
12:55:17 PM: buildId: 63400571924b813fab5b83f8
12:55:17 PM: deployId: 63400571924b813fab5b83fa
12:55:17 PM:
12:55:17 PM: ❯ Current directory
12:55:17 PM: /opt/build/repo/frontend
12:55:17 PM:
12:55:17 PM: ❯ Config file
12:55:17 PM: /opt/build/repo/frontend/netlify.toml
12:55:17 PM:
12:55:17 PM: ❯ Context
12:55:17 PM: branch-deploy
12:55:17 PM:
12:55:17 PM: ────────────────────────────────────────────────────────────────
12:55:17 PM: 1. build.command from netlify.toml
12:55:17 PM: ────────────────────────────────────────────────────────────────
12:55:17 PM:
12:55:17 PM: $ npm run build
12:55:17 PM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
12:55:17 PM: npm WARN config location in the cache, and they are managed by
12:55:17 PM: npm WARN config [`cacache`](http://npm.im/cacache).
12:55:17 PM: > @comvation/website-frontend@0.1.0 build
12:55:17 PM: > astro build
12:55:19 PM: 10:55:19 AM [build] output target: static
12:55:19 PM: 10:55:19 AM [build] Collecting build info...
12:55:19 PM: 10:55:19 AM [build] Completed in 374ms.
12:55:19 PM: 10:55:19 AM [build] Building static entrypoints...
12:55:25 PM: 10:55:25 AM [build] Completed in 5.78s.
12:55:25 PM:
12:55:25 PM: building client
12:55:26 PM: Completed in 1.87s.
12:55:26 PM:
12:55:26 PM:
12:55:26 PM: generating static routes
12:55:26 PM: ▶ src/pages/index.astro
12:55:26 PM: └─ /index.html (+17ms)
...
12:55:27 PM: Completed in 296ms.
12:55:27 PM:
12:55:27 PM: @astrojs/sitemap: `sitemap-index.xml` is created.
12:55:27 PM: 10:55:27 AM [build] 45 page(s) built in 8.34s
12:55:27 PM: 10:55:27 AM [build] Complete!
12:55:27 PM:
12:55:27 PM: (build.command completed in 9.7s)
12:55:27 PM:
12:55:27 PM: ────────────────────────────────────────────────────────────────
12:55:27 PM: 2. Deploy site
12:55:27 PM: ────────────────────────────────────────────────────────────────
12:55:27 PM:
12:55:27 PM: Starting to deploy site from 'frontend/dist'
12:55:27 PM: Creating deploy tree
12:55:27 PM: Creating deploy upload records
12:55:27 PM: 1 new files to upload
12:55:27 PM: 0 new functions to upload
12:55:27 PM: Site deploy was successfully initiated
12:55:27 PM:
12:55:27 PM: (Deploy site completed in 482ms)
12:55:27 PM:
12:55:27 PM: ────────────────────────────────────────────────────────────────
12:55:27 PM: Netlify Build Complete
12:55:27 PM: ────────────────────────────────────────────────────────────────
12:55:27 PM:
12:55:27 PM: (Netlify Build completed in 10.2s)
12:55:27 PM: Starting post processing
12:55:28 PM: Caching artifacts
12:55:28 PM: Started saving node modules
12:55:28 PM: Finished saving node modules
12:55:28 PM: Started saving build plugins
12:55:28 PM: Finished saving build plugins
12:55:28 PM: Started saving pip cache
12:55:28 PM: Finished saving pip cache
12:55:28 PM: Started saving emacs cask dependencies
12:55:28 PM: Post processing - HTML
12:55:28 PM: Finished saving emacs cask dependencies
12:55:28 PM: Started saving maven dependencies
12:55:28 PM: Finished saving maven dependencies
12:55:28 PM: Started saving boot dependencies
12:55:28 PM: Finished saving boot dependencies
12:55:28 PM: Started saving rust rustup cache
12:55:28 PM: Finished saving rust rustup cache
12:55:28 PM: Started saving go dependencies
12:55:28 PM: Finished saving go dependencies
12:55:28 PM: Processing form - contact-form
12:55:28 PM: Detected form fields: - firstname-lastname - customer-need - myextra-field - email - phone - estimated-budget - message
12:55:28 PM: Post processing - header rules
12:55:28 PM: Post processing - redirect rules
12:55:28 PM: Post processing done
12:55:29 PM: Build script success
12:55:30 PM: Uploading Cache of size 341.2MB
12:55:32 PM: Site is live ✨
12:55:32 PM: Finished processing build request in 48.893387198s