mirror of
https://github.com/PaiGramTeam/luoxu-api-pub.git
synced 2024-11-22 07:08:05 +00:00
build: migrate to vite
This commit is contained in:
parent
6f842eed77
commit
210e52af12
@ -7,12 +7,8 @@
|
|||||||
<title>落絮</title>
|
<title>落絮</title>
|
||||||
|
|
||||||
<link rel='icon' type='image/png' href='favicon.png'>
|
<link rel='icon' type='image/png' href='favicon.png'>
|
||||||
<link rel='stylesheet' href='global.css'>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
<link rel='stylesheet' href='build/bundle.css'>
|
|
||||||
|
|
||||||
<script defer src='build/bundle.js'></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
1432
package-lock.json
generated
1432
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -2,30 +2,20 @@
|
|||||||
"name": "svelte-app",
|
"name": "svelte-app",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"dev": "vite",
|
||||||
"dev": "rollup -c -w",
|
"build": "vite build",
|
||||||
"start": "sirv public --no-clear",
|
"preview": "vite preview",
|
||||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@jridgewell/sourcemap-codec": "^1.4.14",
|
"@sveltejs/vite-plugin-svelte": "^2.4.2",
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
"@tsconfig/svelte": "^5.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
"svelte": "^4.0.0",
|
||||||
"@rollup/plugin-terser": "^0.4.0",
|
"svelte-check": "^3.5.2",
|
||||||
"@rollup/plugin-typescript": "^8.0.0",
|
"tslib": "^2.6.0",
|
||||||
"@tsconfig/svelte": "^2.0.1",
|
"typescript": "^5.0.2",
|
||||||
"rollup": "^2.3.4",
|
"vite": "^4.4.5"
|
||||||
"rollup-plugin-css-only": "^3.1.0",
|
|
||||||
"rollup-plugin-livereload": "^2.0.0",
|
|
||||||
"rollup-plugin-svelte": "^7.0.0",
|
|
||||||
"svelte": "^3.56.0",
|
|
||||||
"svelte-check": "^2.0.0",
|
|
||||||
"svelte-preprocess": "^4.0.0",
|
|
||||||
"tslib": "^2.0.0",
|
|
||||||
"typescript": "^4.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"sirv-cli": "^1.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
import svelte from "rollup-plugin-svelte";
|
|
||||||
import commonjs from "@rollup/plugin-commonjs";
|
|
||||||
import resolve from "@rollup/plugin-node-resolve";
|
|
||||||
import livereload from "rollup-plugin-livereload";
|
|
||||||
import terser from "@rollup/plugin-terser";
|
|
||||||
import sveltePreprocess from "svelte-preprocess";
|
|
||||||
import typescript from "@rollup/plugin-typescript";
|
|
||||||
import css from "rollup-plugin-css-only";
|
|
||||||
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
|
||||||
|
|
||||||
function serve() {
|
|
||||||
let server;
|
|
||||||
|
|
||||||
function toExit() {
|
|
||||||
if (server) server.kill(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
writeBundle() {
|
|
||||||
if (server) return;
|
|
||||||
server = require("child_process").spawn(
|
|
||||||
"npm",
|
|
||||||
["run", "start", "--", "--dev"],
|
|
||||||
{
|
|
||||||
// stdio: ['ignore', 'inherit', 'inherit'],
|
|
||||||
// shell: true
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
process.on("SIGTERM", toExit);
|
|
||||||
process.on("exit", toExit);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
input: "src/main.ts",
|
|
||||||
output: {
|
|
||||||
sourcemap: true,
|
|
||||||
format: "iife",
|
|
||||||
name: "app",
|
|
||||||
file: "public/build/bundle.js",
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
svelte({
|
|
||||||
preprocess: sveltePreprocess({ sourceMap: !production }),
|
|
||||||
compilerOptions: {
|
|
||||||
// enable run-time checks when not in production
|
|
||||||
dev: !production,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
// we'll extract any component CSS out into
|
|
||||||
// a separate file - better for performance
|
|
||||||
css({ output: "bundle.css" }),
|
|
||||||
|
|
||||||
// If you have external dependencies installed from
|
|
||||||
// npm, you'll most likely need these plugins. In
|
|
||||||
// some cases you'll need additional configuration -
|
|
||||||
// consult the documentation for details:
|
|
||||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
|
||||||
resolve({
|
|
||||||
browser: true,
|
|
||||||
dedupe: ["svelte"],
|
|
||||||
}),
|
|
||||||
commonjs(),
|
|
||||||
typescript({
|
|
||||||
sourceMap: true,
|
|
||||||
//sourceMap: !production,
|
|
||||||
inlineSources: !production,
|
|
||||||
}),
|
|
||||||
|
|
||||||
// In dev mode, call `npm run start` once
|
|
||||||
// the bundle has been generated
|
|
||||||
!production && serve(),
|
|
||||||
|
|
||||||
// Watch the `public` directory and refresh the
|
|
||||||
// browser on changes when not in production
|
|
||||||
!production && livereload("public"),
|
|
||||||
|
|
||||||
// If we're building for production (npm run build
|
|
||||||
// instead of npm run dev), minify
|
|
||||||
production && terser(),
|
|
||||||
],
|
|
||||||
watch: {
|
|
||||||
buildDelay: 500,
|
|
||||||
clearScreen: false,
|
|
||||||
},
|
|
||||||
};
|
|
@ -3,6 +3,7 @@
|
|||||||
import Message from "./Message.svelte";
|
import Message from "./Message.svelte";
|
||||||
import Name from "./Name.svelte";
|
import Name from "./Name.svelte";
|
||||||
import { sleep } from "./util.js";
|
import { sleep } from "./util.js";
|
||||||
|
import "./global.css";
|
||||||
|
|
||||||
const LUOXU_URL = "https://lab.lilydjwg.me/luoxu";
|
const LUOXU_URL = "https://lab.lilydjwg.me/luoxu";
|
||||||
const islocal = LUOXU_URL.startsWith("http://localhost");
|
const islocal = LUOXU_URL.startsWith("http://localhost");
|
||||||
|
1
src/global.d.ts
vendored
1
src/global.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
/// <reference types="svelte" />
|
|
2
src/vite-env.d.ts
vendored
Normal file
2
src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/// <reference types="svelte" />
|
||||||
|
/// <reference types="vite/client" />
|
7
svelte.config.js
Normal file
7
svelte.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
|
||||||
|
// for more information about preprocessors
|
||||||
|
preprocess: vitePreprocess(),
|
||||||
|
}
|
@ -1,16 +1,20 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": [
|
"target": "ESNext",
|
||||||
"ES2020",
|
"useDefineForClassFields": true,
|
||||||
"DOM"
|
"module": "ESNext",
|
||||||
]
|
"resolveJsonModule": true,
|
||||||
|
/**
|
||||||
|
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||||
|
* Disable checkJs if you'd like to use dynamic types in JS.
|
||||||
|
* Note that setting allowJs false does not prevent the use
|
||||||
|
* of JS in `.svelte` files.
|
||||||
|
*/
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"isolatedModules": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
||||||
"src/**/*"
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules/*",
|
|
||||||
"__sapper__/*",
|
|
||||||
"public/*"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
9
tsconfig.node.json
Normal file
9
tsconfig.node.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler"
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
7
vite.config.ts
Normal file
7
vite.config.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [svelte()],
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user