Skip to content

ci: try webpack cache #6269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: yarn

- name: Enable webpack persistent caching
uses: actions/cache@v3
id: build-webpack-persistent-cache
with:
path: node_modules/.cache
key: build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |-
build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
build-${{ hashFiles('**/webpack.*.mjs') }}-

- run: yarn --frozen-lockfile
- name: Build site
run: yarn build
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ jobs:

- run: yarn

- name: Enable webpack persistent caching
uses: actions/cache@v3
id: build-webpack-persistent-cache
with:
path: node_modules/.cache
key: build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |-
build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
build-${{ hashFiles('**/webpack.*.mjs') }}-

- name: Build site
run: yarn build
env:
Expand All @@ -74,6 +84,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Enable webpack persistent caching
uses: actions/cache@v3
id: build-webpack-persistent-cache
with:
path: node_modules/.cache
key: build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |-
build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
build-${{ hashFiles('**/webpack.*.mjs') }}-

- name: Cypress run
uses: cypress-io/github-action@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"prettier": "prettier --write '**/*.{js,json,jsx,css,scss,md,mdx}'",
"prepare": "husky install"
"prepare": "husky install",
"postinstall": "rimraf ./node_modules/.cache/webpack"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to clear the cache here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"lint-staged": {
"*.{js,jsx,md,mdx}": [
Expand Down
2 changes: 1 addition & 1 deletion webpack.common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default ({ ssg = false }) => ({
buildDependencies: {
config: [__filename],
},
cacheDirectory: path.resolve(__dirname, '.cache/webpack'),
cacheDirectory: path.resolve(__dirname, 'node_modules/.cache/webpack')
},
resolve: {
extensions: ['.js', '.jsx', '.scss'],
Expand Down
5 changes: 0 additions & 5 deletions webpack.prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ import ProdAssetsManifest from './src/ProdAssetsManifest.mjs';
export default (env) =>
merge(common(env), {
mode: 'production',
cache: {
buildDependencies: {
config: [__filename],
},
},
entry: {
index: {
import: './index.jsx',
Expand Down
5 changes: 0 additions & 5 deletions webpack.ssg.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export default (env) =>
name: 'ssg',
mode: 'production',
target: 'node',
cache: {
buildDependencies: {
config: [__filename],
},
},
module: {
parser: {
javascript: {
Expand Down