Skip to content

Commit be0dc50

Browse files
committed
add lesson 4-2: optimize images start
1 parent 22abc67 commit be0dc50

File tree

147 files changed

+30667
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+30667
-0
lines changed

.github/workflows/optimize-images.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Optimize Images
2+
on:
3+
pull_request:
4+
paths:
5+
- '42-optimize/**/*.jpg'
6+
- '42-optimize/**/*.jpeg'
7+
- '42-optimize/**/*.png'
8+
- '42-optimize/**/*.webp'
9+
jobs:
10+
build:
11+
# Only run on Pull Requests within the same repository, and not from forks.
12+
if: github.event.pull_request.head.repo.full_name == github.repository
13+
name: calibreapp/image-actions
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v2
18+
19+
- name: Compress Images
20+
uses: calibreapp/image-actions@main
21+
with:
22+
githubToken: ${{ secrets.GITHUB_TOKEN }}
23+
jpegQuality: '80'
24+
jpegProgressive: false
25+
pngQuality: '80'
26+
webpQuality: '80'

42-optimize-images/.eslintrc

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"es6": true
7+
},
8+
"plugins": [
9+
"eslint-plugin-html",
10+
"simple-import-sort",
11+
"import"
12+
],
13+
"extends": [
14+
"eslint:recommended",
15+
"plugin:prettier/recommended"
16+
],
17+
"rules": {
18+
"no-console": ["error", { "allow": ["error"] }],
19+
"no-var": "error",
20+
"object-shorthand": "error",
21+
"prefer-const": "error",
22+
"prefer-template": "error",
23+
"prefer-destructuring": "warn",
24+
"prefer-rest-params": "warn",
25+
"prefer-spread": "warn",
26+
"yoda": "error",
27+
"simple-import-sort/imports": "error",
28+
"simple-import-sort/exports": "error",
29+
"import/first": "error",
30+
"import/newline-after-import": "error",
31+
"import/no-duplicates": "error"
32+
}
33+
}

42-optimize-images/.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Dependency directories
9+
node_modules/
10+
11+
# Optional npm cache directory
12+
.npm
13+
14+
# Optional eslint cache
15+
.eslintcache
16+
17+
# Output of 'npm pack'
18+
*.tgz
19+
20+
# Yarn Integrity file
21+
.yarn-integrity
22+
23+
# dotenv environment variables file
24+
.env
25+
.env.test
26+
27+
# Build output
28+
dist

42-optimize-images/.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

42-optimize-images/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 CodelyTV
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

42-optimize-images/README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# JavaScript Bootstrap (base / project starter)
2+
3+
This is a repository intended to serve as a starting point if you want to bootstrap a project in modern vanilla JavaScript.
4+
5+
## Features
6+
7+
- [Webpack](https://webpack.js.org/) (v5)
8+
- [Babel](https://babeljs.io/) with [preset-env](https://babeljs.io/docs/en/babel-preset-env)
9+
- [Prettier](https://prettier.io/)
10+
- [ESLint](https://eslint.org/) with:
11+
- [Simple Import Sort](https://github.com/lydell/eslint-plugin-simple-import-sort/)
12+
- [Import plugin](https://github.com/benmosher/eslint-plugin-import/)
13+
- [HTML plugin](https://github.com/BenoitZugmeyer/eslint-plugin-html)
14+
- And a few other ES2015+ related rules
15+
- [Jest](https://jestjs.io) with [DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro)
16+
- [Cypress](https://www.cypress.io/) with [Testing Library](https://testing-library.com/docs/cypress-testing-library/)
17+
- [GitHub Action workflows](https://github.com/features/actions) set up to run tests and linting on push
18+
19+
## Running the app
20+
21+
```
22+
# install dependencies
23+
npm install
24+
25+
# run in dev mode on port 8080
26+
npm run dev
27+
28+
# generate production build
29+
npm run build
30+
31+
# run generated content in dist folder on port 8080
32+
npm run start
33+
```
34+
35+
## Testing
36+
37+
### Jest with Testing Library
38+
39+
```
40+
npm run test
41+
```
42+
43+
### Cypress
44+
45+
```
46+
# run in dev mode on port 8080
47+
npm run dev
48+
49+
# open Cypress to run tests on dev mode
50+
npm run cy:open
51+
52+
# open Cypress on CLI
53+
npm run cy:run
54+
```
55+
56+
## Linting
57+
58+
```
59+
# run linter
60+
npm run lint
61+
62+
# fix lint issues
63+
npm run lint:fix
64+
```

42-optimize-images/babel.config.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"useBuiltIns": "usage",
7+
"corejs": "3.9.1"
8+
}
9+
]
10+
]
11+
}

0 commit comments

Comments
 (0)