root: add config and scripts for processing ts and css files

Adds dependencies for PostCSS and TypeScript with build
and develop scripts that use them in package.json.

Removes tsconfig parser option from eslintrc because it interferes
with a change in the tsconfig to exclude test files. We want eslint
to still lint test files. This is okay for now because none of our
lint rules depend on type information. If we add rules that require
type info we can create a separate tsconfig for eslint.

This change adds TypeScript but not esbuild. It is not
clear that we need minification so we will start with just
the TypeScript compiler for now. Looking at some of the sources
we currently minify with the closure compiler typical savings in
a file is less than 1kb. Once we have some TypeScript
code to compare minified and unminified performance with we
can consider adding esbuild or some other minifier.

For golang/go#43359
For golang/go#43360

Change-Id: I1a181952f546b0a0eb9b755128b2b83481e8ed92
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280705
Reviewed-by: Julie Qiu <julie@golang.org>
Trust: Jamal Carvalho <jamal@golang.org>
This commit is contained in:
Jamal Carvalho 2020-12-30 14:24:46 -05:00
Родитель 53de88f2e2
Коммит 34f05b6095
4 изменённых файлов: 2670 добавлений и 4 удалений

Просмотреть файл

@ -1,7 +1,5 @@
root: true
parser: '@typescript-eslint/parser'
parserOptions:
project: './tsconfig.json'
env:
browser: true
plugins:

2652
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -6,6 +6,12 @@
},
"private": true,
"scripts": {
"build": "run-p build-*",
"build-js": "tsc --project .",
"build-css": "postcss content/lib/css/*.css --map --use autoprefixer cssnano --dir content/static/css",
"develop": "run-p develop-*",
"develop-js": "tsc --project . --watch",
"develop-css": "postcss content/lib/css/*.css --use autoprefixer --dir content/static/css --watch",
"lint": "run-s --continue-on-error \"lint-* -- {1}\" -- ",
"lint-js": "eslint . --ext .ts",
"lint-css": "stylelint **/*.css",
@ -21,6 +27,8 @@
"@types/puppeteer": "5.4.0",
"@typescript-eslint/eslint-plugin": "4.5.0",
"@typescript-eslint/parser": "4.5.0",
"autoprefixer": "10.0.2",
"cssnano": "4.1.10",
"eslint": "7.12.0",
"eslint-config-prettier": "6.14.0",
"eslint-plugin-jest": "24.1.3",
@ -29,6 +37,8 @@
"jest-image-snapshot": "4.2.0",
"js-green-licenses": "2.0.1",
"npm-run-all": "4.1.5",
"postcss": "^8.2.1",
"postcss-cli": "8.3.0",
"prettier": "2.1.2",
"puppeteer": "5.5.0",
"stylelint": "13.8.0",

Просмотреть файл

@ -14,7 +14,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
"outDir": "./content/static/js", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
@ -65,5 +65,11 @@
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
},
"include": [
"content/lib/ts"
],
"exclude": [
"**/*.test.ts"
]
}