Initial commit
This commit is contained in:
commit
dd26552ed5
2
.env
Normal file
2
.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
IS_PRODUCTION=true
|
||||||
|
FOO=bar
|
2
.env.development
Normal file
2
.env.development
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
IS_PRODUCTION=false
|
||||||
|
FOO=bar
|
31
.eslintignore
Normal file
31
.eslintignore
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.json",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["@typescript-eslint"],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||||
|
"plugin:prettier/recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"max-len": ["error", {"code": 120, "ignoreComments": true, "ignoreTemplateLiterals": true}],
|
||||||
|
"no-console": "error",
|
||||||
|
"semi": [ "error", "always" ],
|
||||||
|
"sort-imports": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"ignoreCase": false,
|
||||||
|
"ignoreDeclarationSort": false,
|
||||||
|
"ignoreMemberSort": false,
|
||||||
|
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
|
||||||
|
"allowSeparatedGroups": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
31
.eslintrc
Normal file
31
.eslintrc
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.json",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["@typescript-eslint"],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||||
|
"plugin:prettier/recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"max-len": ["error", {"code": 120, "ignoreComments": true, "ignoreTemplateLiterals": true}],
|
||||||
|
"no-console": "error",
|
||||||
|
"semi": [ "error", "always" ],
|
||||||
|
"sort-imports": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"ignoreCase": false,
|
||||||
|
"ignoreDeclarationSort": false,
|
||||||
|
"ignoreMemberSort": false,
|
||||||
|
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
|
||||||
|
"allowSeparatedGroups": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.parcel-cache
|
6
.parcelrc
Normal file
6
.parcelrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": "@parcel/config-default",
|
||||||
|
"transformers": {
|
||||||
|
"*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
|
||||||
|
}
|
||||||
|
}
|
7
.prettierrc.json
Normal file
7
.prettierrc.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"endOfLine": "auto",
|
||||||
|
"semi": true,
|
||||||
|
"printWidth": 120
|
||||||
|
}
|
6
@types/process.d.ts
vendored
Normal file
6
@types/process.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
declare const process: {
|
||||||
|
env: {
|
||||||
|
ENV: string;
|
||||||
|
URL: string;
|
||||||
|
}
|
||||||
|
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 Michal Szczepanski (michal@vane.pl)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
17
README.md
Normal file
17
README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Typescript parceljs html page template
|
||||||
|
* parceljs
|
||||||
|
* typescript
|
||||||
|
* linter - eslint with @typescript-eslint
|
||||||
|
* prettier
|
||||||
|
* pre-commit hook for lint
|
||||||
|
* reading .env files
|
||||||
|
* simple HMR using `window.location.reload()`
|
||||||
|
|
||||||
|
### Development
|
||||||
|
```npm run dev```
|
||||||
|
|
||||||
|
starts server hosted on port
|
||||||
|
```localhost:1234```
|
||||||
|
|
||||||
|
### Production
|
||||||
|
``npm run prod``
|
7355
package-lock.json
generated
Normal file
7355
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "typescript-parcel-base",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "parcel src/index.html",
|
||||||
|
"prod": "parcel build src/index.html",
|
||||||
|
"lint": "eslint --ext .ts src/",
|
||||||
|
"lint:fix": "eslint --ext .ts,.tsx src/ --fix"
|
||||||
|
},
|
||||||
|
"pre-commit": [
|
||||||
|
"lint"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"@parcel/transformer-typescript-tsc": "^2.8.3",
|
||||||
|
"@types/node": "^18.11.18",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
||||||
|
"@typescript-eslint/parser": "^5.48.2",
|
||||||
|
"eslint": "^8.32.0",
|
||||||
|
"eslint-config-prettier": "^8.6.0",
|
||||||
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
|
"parcel": "^2.8.3",
|
||||||
|
"pre-commit": "^1.2.2",
|
||||||
|
"typescript": "^4.9.4"
|
||||||
|
}
|
||||||
|
}
|
4
src/config.ts
Normal file
4
src/config.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export const Config = {
|
||||||
|
isProduction: process.env.IS_PRODUCTION === 'true',
|
||||||
|
foo: process.env.FOO
|
||||||
|
};
|
10
src/index.html
Normal file
10
src/index.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Hello World</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="module" src="index.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
12
src/index.ts
Normal file
12
src/index.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { Config } from './config';
|
||||||
|
const h1 = document.createElement('h1');
|
||||||
|
document.body.appendChild(h1);
|
||||||
|
h1.innerText = `is production ${Config.isProduction.toString()}, foo value from .env: ${Config.foo || ''}`;
|
||||||
|
|
||||||
|
// Hot reloading
|
||||||
|
if (!Config.isProduction) {
|
||||||
|
const ws = new WebSocket('ws://localhost:1234');
|
||||||
|
ws.onmessage = () => {
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
}
|
8
tsconfig.json
Normal file
8
tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2021",
|
||||||
|
"strict": true,
|
||||||
|
"typeRoots": ["node_modules/@types", "@types"]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user