Skip to content

Commit

Permalink
refactor: reconfig dev and build env with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
ACTCD committed Nov 18, 2022
1 parent d4fea28 commit cfc5f02
Show file tree
Hide file tree
Showing 145 changed files with 2,566 additions and 56,370 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
build
/etc
14 changes: 4 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"env": {
"browser": true,
"node": true,
"es2021": true,
"node": true
"es2022": true,
"webextensions": true
},
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaVersion": 12,
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["svelte3"],
Expand All @@ -20,14 +22,6 @@
"_browser": "writable",
"browser": "readonly"
},
"ignorePatterns": [
"node_modules/",
"public/*/build/",
"codemirror/",
"etc/",
"extension/Userscripts Extension/Resources/page.js",
"extension/Userscripts Extension/Resources/popup.js"
],
"rules": {
"array-bracket-spacing": ["error", "never"],
"arrow-parens": ["error", "as-needed"],
Expand Down
7 changes: 0 additions & 7 deletions .gitattributes

This file was deleted.

35 changes: 31 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
temp
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
!.vscode/tasks.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# OS generated files
.DS_Store
.DS_Store?
Expand All @@ -7,10 +34,10 @@
ehthumbs.db
Thumbs.db

/node_modules/
/public/*/build/
/temp/

# xcode
xcuserdata/
*.xcuserstate
XCBuildData
xcode/**/build/
xcode/**/dist/
# xcode/Userscripts-iOS/Base.lproj/Main.html
5 changes: 5 additions & 0 deletions .postcssrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"autoprefixer": {"overrideBrowserslist": ["safari >= 13"]}
}
}
5 changes: 5 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
build
/etc
reset.css
1 change: 0 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"stylelint-config-standard",
"stylelint-config-html/svelte"
],
"ignoreFiles": ["**/codemirror/*", "**/reset.css", "**/*.js"],
"rules": {
"alpha-value-notation": "number",
"comment-empty-line-before": ["always",{
Expand Down
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"svelte.svelte-vscode",
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint"
]
}
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@
"svelte.plugin.svelte.compilerWarnings": {
"a11y-missing-attribute": "error"
},
"svelte.plugin.svelte.rename.enable": false
"svelte.plugin.svelte.rename.enable": false,
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"[css]": {
"editor.defaultFormatter": "stylelint.vscode-stylelint"
}
}
63 changes: 63 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "pnpm: install",
"detail": "Install dev dependencies",
"type": "shell",
"command": "pnpm install",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "pnpm: dev",
"detail": "Run dev server",
"type": "shell",
"command": "pnpm dev",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "pnpm: build",
"detail": "Build to xcode dist path",
"type": "shell",
"command": "pnpm build",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "xcode: build",
"detail": "xcodebuild",
"type": "shell",
"command": "xcodebuild -scheme Userscripts build",
"group": "build",
"options": {
"cwd": "./xcode/"
}
},
{
"label": "xcode: rebuild",
"detail": "pnpm build + xcodebuild",
"presentation": {
"reveal": "silent"
},
"dependsOrder": "sequence",
"dependsOn": [
"pnpm: build",
"xcode: build"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
22 changes: 0 additions & 22 deletions ISSUE_TEMPLATE.md

This file was deleted.

Empty file added doc/contribute.md
Empty file.
23 changes: 23 additions & 0 deletions doc/dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The `root` directory is a typical multi-page app of Vite with Svelte JavaScript project.

The `xcode` directory is the root of the Xcode project where the Safari extension app is built.

# Environment
- [`Node.js`](https://nodejs.dev/en/learn/how-to-install-nodejs/)
- [`pnpm`](https://pnpm.io/installation) (optional)
- [`Xcode`](https://geo.itunes.apple.com/app/xcode/id497799835)

# Dev
- `pnpm install`
- `pnpm dev`

# Build
- `pnpm build`
- `cd ./xcode`
- `xcodebuild` or build with Xcode App

# Contribute
[Contribution Guidelines](contribute.md)

# About
Userscripts @ 2022
47 changes: 47 additions & 0 deletions doc/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Svelte + Vite

This template should help get you started developing with Svelte in Vite.

## Recommended IDE Setup

[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).

## Need an official Svelte framework?

Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.

## Technical considerations

**Why use this over SvelteKit?**

- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.

This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.

Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.

**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**

Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.

**Why include `.vscode/extensions.json`?**

Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.

**Why enable `checkJs` in the JS template?**

It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.

**Why is HMR not preserving my local component state?**

HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).

If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.

```js
// store.js
// An extremely simple external store
import { writable } from 'svelte/store'
export default writable(0)
```
14 changes: 14 additions & 0 deletions entry-background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark">
<title>background</title>
</head>
<body>
<noscript>Please enable Javascript to use this app</noscript>
<div id="app"></div>
<script type="module" src="/src/background/main.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions entry-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark">
<title>Userscripts page</title>
</head>
<body>
<noscript>Please enable Javascript to use this app</noscript>
<div id="app"></div>
<script type="module" src="/src/page/main.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions entry-popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark">
<title>Userscripts popup</title>
</head>
<body>
<noscript>Please enable Javascript to use this app</noscript>
<div id="app"></div>
<script type="module" src="/src/popup/main.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion extension/Userscripts Extension/Resources/page.html

This file was deleted.

21,518 changes: 0 additions & 21,518 deletions extension/Userscripts Extension/Resources/page.js

This file was deleted.

Loading

0 comments on commit cfc5f02

Please sign in to comment.