Skip to content

Commit

Permalink
Merge pull request #279 from greatislander/mix-six
Browse files Browse the repository at this point in the history
feat: upgrade to Laravel Mix 6.x
  • Loading branch information
SteelWagstaff authored Jun 29, 2021
2 parents 37eaa5d + e5cb388 commit 303e86d
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 14,472 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache node modules
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: npm install and test
run: |
npm install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
assets/dist
node_modules
package-lock.json
.idea/
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,32 @@ NPM package which includes all asset linting and build tools for Pressbooks proj
When installing `pressbooks-build-tools` you install 955+ directories under `node_modules`. These modules are used to compile and copy files to `assets/dist`. These
`node_modules` are never used in our code, never deployed.

When maintaining dozens & dozens of plugins & themes, 1 dependabot nag about some module in `pressbooks-build-tools` equals updating many, many GitHub repos to fix code we never
deploy. It's not fun. For this reason we don't include `pressbooks-build-tools` in our plugins or themes `package.json` file.
When maintaining dozens & dozens of plugins & themes, 1 dependabot nag about some module in `pressbooks-build-tools` equals updating many, many GitHub repos to fix code we never
deploy. It's not fun. For this reason we don't include `pressbooks-build-tools` in our plugins or themes `package.json` file.

## Upgrading to 3.0

Version 3.0 of `pressbooks-build-tools` includes Laravel Mix 6.0, and as such will require some [changes to build scripts](https://laravel-mix.com/docs/6.0/upgrade#update-your-npm-scripts) wherever it is used. For example, the build task used in testing this package used to require the following script:

```shell
cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
```

The same build task can now be run using a new `mix` executable with an appropriate flag:

```shell
mix --production
```

For the full list of scripts and their replacements, see the [Laravel Mix documentation](https://laravel-mix.com/docs/6.0/upgrade#update-your-npm-scripts).

## Test Your Changes

This repo includes a boilerplate `webpack.mix.js` configuration used to test that, at the very least, `.js` and `.scss` files compile. To run the test do:
This repo includes a boilerplate `webpack.mix.js` configuration used to test that, at the very least, `.js` and `.scss` files compile and that linters run. To run the test do:

```
npm install
npm run test
```

Expected: No errors. Everything is fine.
Expected: No errors. Everything is fine.
7 changes: 6 additions & 1 deletion assets/src/scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
jQuery( function ( $ ) {

/**
*
* @param {number} n The input number.
* @returns {number} The next number in the Fibonacci sequence.
*/
function fibonacci( n ) {
return n < 1 ? 0
: n <= 2 ? 1
: fibonacci( n - 1 ) + fibonacci( n - 2 );
}

fibonacci( 4 );

} );
2 changes: 1 addition & 1 deletion assets/src/styles/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ body {
font-weight: bold;
}
}
}
}
1 change: 0 additions & 1 deletion config/stylelint.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports = {
extends: [
'stylelint-config-recommended-scss',
Expand Down
Loading

0 comments on commit 303e86d

Please sign in to comment.