简体   繁体   中英

Snowpack is not reloading

i started to use snowpack and ran into a big problem. Snowpack is not hot reloading for me. I tried the basic minimal template, a svelte template and a react template - Everytime the same problem. I also created on from scratch based on the getting started.

Here a my example files:

index.jsx

import React from 'https://cdn.skypack.dev/react';
import ReactDom from 'https://cdn.skypack.dev/react-dom';

ReactDom.render(
  <React.StrictMode>
    <div>This is working</div>
  </React.StrictMode>,
  document.getElementById('root'),
);

// Hot Module Replacement (HMR) - Remove this snippet to remove HMR.
// Learn more: https://www.snowpack.dev/concepts/hot-module-replacement
if (import.meta.hot) {
  import.meta.hot.accept();
}

snowpack.config.js

/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
  mount: {
    public: { url: '/', static: true },
    src: { url: '/dist' },
  },
  plugins: ['@snowpack/plugin-react-refresh'],
  packageOptions: {
    /* ... */
  },
  devOptions: {
    /* ... */
  },
  buildOptions: {
    /* ... */
  },
};

package.json

{
  "name": "chatclient",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "snowpack dev",
    "build": "snowpack build",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@snowpack/plugin-react-refresh": "^2.4.0",
    "snowpack": "^3.0.11"
  }
}

I hope someone can help me. Snowpack is such an amazing tool but i can't get it to work.

I found a solution

Credits

I used to run my dev environment on wsl2. Some no known reason does nodejs not hot reload when you are in wsl2 and the files are on the windows filesystem. Moved everything to my linux filesystem and i worked.

I hope someone will find this helpful!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM