升级到 Snowpack 3 后找不到文件

After upgrading to Snowpack 3 cannot find files

我正在使用 Snowpack + Svelte。升级到 Snowpack 3 后不再工作,我无法在 snowpack.config.js 中正确配置 mount

不明白为什么它找不到 App.js 而且它正在尝试找到 .jsx.ts...

[404] /_dist_/screens/App.js

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="stylesheet" href="global.css">
    <script type="module" defer src="_dist_/main.js"></script>
</head>

<body>
</body>
</html>

然后在我的snowpack.config.js

/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
  mount: {
    public: '/',
    src: '/_dist_',
  },
  plugins: [
    '@snowpack/plugin-svelte',
    '@snowpack/plugin-dotenv',
  ],
  routes: [
    /* Enable an SPA Fallback in development: */
    // {"match": "routes", "src": ".*", "dest": "/index.html"},
  ],
  optimize: {
    /* Example: Bundle your final build: */
    // "bundle": true,
  },
  packageOptions: {
    /* ... */
  },
  devOptions: {
    /* ... */
  },
  buildOptions: {
    /* ... */
  },
  alias: {
    components: './src/components',
    screens: './src/screens',
    lib: './src/lib'
  },
};

我也试过:

  mount: {
    // Same behavior as the "src" example above:
    "src": {url: "/dist"},
    // Mount "public" to the root URL path ("/*") and serve files with zero transformations:
    "public": {url: "/", static: true, resolve: false}
  },

所以现在抱怨少了但仍然没有用

[snowpack] [404] /_dist_/main.js

文件结构

root
--node-modules
--public
----global.css
----index.html
--src
----components
----lib
----screens
----main.js
--snowpack.config.js
...

package.json

  "devDependencies": {
    "@snowpack/plugin-dotenv": "^2.0.5",
    "@snowpack/plugin-svelte": "^3.5.0",
    "@snowpack/web-test-runner-plugin": "^0.2.1",
    "@testing-library/svelte": "^3.0.3",
    "@web/test-runner": "^0.12.2",
    "chai": "^4.2.0",
    "smart-webcomponents": "^9.0.0",
    "snowpack": "^3.0.10",
    "svelte": "^3.31.2",
    "svelte-i18n": "^3.3.0"
  }

任何帮助或想法将不胜感激。

只需在导入组件时添加 .svelte

import App from 'screens/App.svelte'

如果您想深入了解,请检查此 https://github.com/snowpackjs/snowpack/pull/2014#issuecomment-756624333