1

我正在尝试部署一个使用 Snowpack 作为构建工具和 Routify 用于处理 Netlify 上的路由的 Svelte 应用程序。当我在本地运行 build 命令时,一切正常,但是在 Netlify 实例上,没有生成 .routify 文件夹,因此在 App 脚本中无法访问路由。该项目的配置如下:

package.json 是

{
  "scripts": {
    "start": "run-p routify snp",
    "build": "run-s build:*",
    "build:routify": "routify -b",
    "build:snowpack": "snowpack build",
    "test": "web-test-runner \"src/**/*.test.ts\"",
    "routify": "routify",
    "snp": "snowpack dev"
  },
  "dependencies": {
    "@snowpack/plugin-run-script": "^2.3.0",
    "postcss-import": "^14.0.2",
    "svelte": "^3.37.0"
  },
  "devDependencies": {
    "@roxi/routify": "^2.18.3",
    "@snowpack/plugin-dotenv": "^2.2.0",
    "@snowpack/plugin-postcss": "^1.4.3",
    "@snowpack/plugin-svelte": "^3.6.1",
    "@snowpack/plugin-typescript": "^1.2.1",
    "@snowpack/web-test-runner-plugin": "^0.2.2",
    "@testing-library/svelte": "^3.0.3",
    "@tsconfig/svelte": "^1.0.10",
    "@types/chai": "^4.2.17",
    "@types/mocha": "^8.2.2",
    "@types/snowpack-env": "^2.3.3",
    "@web/test-runner": "^0.13.3",
    "autoprefixer": "^10.4.0",
    "chai": "^4.3.4",
    "concurrently": "^6.4.0",
    "cross-env": "^7.0.3",
    "npm-run-all": "^4.1.5",
    "postcss": "^8.3.11",
    "postcss-cli": "^9.0.2",
    "postcss-load-config": "^3.1.0",
    "snowpack": "^3.8.7",
    "svelte-preprocess": "^4.7.2",
    "tailwindcss": "^2.2.19",
    "typescript": "^4.3.4"
  },
  "routify": {
    "extensions": "svelte,html,svx,md",
    "dynamicImports": false,
    "routifyDir": "src/.routify"
  }
}

和 snowpack.config.js 是

/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
  mount: {
    public: { url: "/", static: true },
    src: { url: "/dist" },
    '.routify': { url: '/dist/.routify' },
  },
  plugins: [
    "@snowpack/plugin-svelte",
    "@snowpack/plugin-dotenv",
    "@snowpack/plugin-typescript",
    "@snowpack/plugin-postcss",
  ],
  routes: [
    /* Enable an SPA Fallback in development: */
    { match: "routes", src: ".*", dest: "/index.html" },
  ],
  optimize: {
    /* Example: Bundle your final build: */
    // "bundle": true,
  },
  packageOptions: {
    knownEntrypoints: ["@roxi/routify/runtime/buildRoutes"],
  },
  devOptions: {
    /* ... */
  },
  buildOptions: {
    /* ... */
  },
};

routify 有问题还是我的配置中缺少某些东西?

4

0 回答 0