squoosh: Error: Could not load css

src/static-build/index.tsx → .tmp/build...
[!] (plugin css) Error: Could not load css:/squoosh-dev/src/shared/prerendered-app/colors.css (imported by  initialCss): Cannot find \squoosh-dev\src\shared\prerendered-app\colors.css in pathToResult
Error: Could not load css:/squoosh-dev/src/shared/prerendered-app/colors.css (imported by  initialCss): Cannot find \squoosh-dev\src\shared\prerendered-app\colors.css in pathToResult
    at Object.load (F:\squoosh-dev\rollup.config.js:552:17)
    at F:\squoosh-dev\node_modules\rollup\dist\shared\rollup.js:18971:25

windows 10 x64 npm 16

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 17

Most upvoted comments

Closing this due to lack of details.

请切换到其他版本的nodejs来尝试构建 Please switch to a different version of nodejs to try building it

such as nodejs 14

To anyone wanting to get it working on Windows on more recent versions of Node.js, these are the steps I’ve taken on commit https://github.com/GoogleChromeLabs/squoosh/commit/d87eff7645c151c2f4365c2515c71f4e56ed71ca (latest at the time of writing) to get it working:

  1. Open lib\css-plugin.js and go to line 163.
  2. Replace the const with a let to allow modification:
  3. Add a condition that adds the current disk’s letter in front of the string if it’s missing:
- const path = nomalizePath(id.slice(sourcePrefix.length));
+ let path = nomalizePath(id.slice(sourcePrefix.length));
+ if (path.startsWith("\\")) path = "C:" + path

Make sure to replace C with D or whatever disk that project is running on.

  1. Run npm run build
  2. Done

To get it running locally, I had to take these steps, not sure if they’re really required:

  1. In package.json, update the serve script to use the ./build folder instead of .tmp/build/static:
  2. Hardcode the port you want to use as Windows doesn’t seem to support setting env vars like it’s done in the dev script:
- "serve": "serve --listen=$DEV_PORT --config ../../../serve.json .tmp/build/static",
+ "serve": "serve --listen=5000 --config ../serve.json ./build",
  1. Run npm run serve
  2. Done

i have the same problem

same problem. And I solve it by use node version of v14