Update plugin zip build script with additional options. (https://github.com/woocommerce/woocommerce-blocks/pull/1893)
* update plugin build script to allow for development builds * add new npm scripts to package.json - running dev build without watch - building a plugin zip for dev build. * tweak script to have zip only build * update docs to include new build options * improve command docs
This commit is contained in:
parent
e769516758
commit
be5dfbd565
|
@ -3,6 +3,37 @@
|
|||
# Exit if any command fails.
|
||||
set -e
|
||||
|
||||
TYPE='PRODUCTION';
|
||||
|
||||
print_usage() {
|
||||
echo "build-plugin-zip - attempt to build a plugin"
|
||||
echo "By default this will build a clean production build and zip archive"
|
||||
echo "of the built plugin assets"
|
||||
echo " "
|
||||
echo "build-plugin-zip [arguments]"
|
||||
echo " "
|
||||
echo "options:"
|
||||
echo "-h show brief help"
|
||||
echo "-d build plugin in development mode"
|
||||
echo "-z build zip only, skipping build commands (so it uses files"
|
||||
echo " existing on disk already)"
|
||||
echo " "
|
||||
}
|
||||
|
||||
# get args
|
||||
while getopts 'hdz' flag; do
|
||||
case "${flag}" in
|
||||
h) print_usage ;;
|
||||
d) TYPE='DEV' ;;
|
||||
z) TYPE='ZIP_ONLY' ;;
|
||||
*)
|
||||
print_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# Store paths
|
||||
SOURCE_PATH=$(pwd)
|
||||
|
||||
|
@ -79,17 +110,32 @@ if [ -z "$NO_CHECKS" ]; then
|
|||
fi
|
||||
|
||||
# Run the build.
|
||||
status "Installing dependencies... 📦"
|
||||
composer install --no-dev
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install
|
||||
status "==========================="
|
||||
npm list webpack
|
||||
status "Generating build... 👷♀️"
|
||||
status "==========================="
|
||||
npm list webpack
|
||||
npm run build
|
||||
status "==========================="
|
||||
npm list webpack
|
||||
if [ $TYPE = 'DEV' ]; then
|
||||
status "Installing dependencies... 👷♀️"
|
||||
status "==========================="
|
||||
composer install
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install
|
||||
status "==========================="
|
||||
status "Generating development build... 👷♀️"
|
||||
status "==========================="
|
||||
npm list webpack
|
||||
npm run dev
|
||||
status "==========================="
|
||||
elif [ $TYPE = 'ZIP_ONLY' ]; then
|
||||
status "Skipping build commands - using current built assets on disk for built archive...👷♀️"
|
||||
status "==========================="
|
||||
else
|
||||
status "Installing dependencies... 📦"
|
||||
composer install --no-dev
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install
|
||||
status "==========================="
|
||||
status "Generating production build... 👷♀️"
|
||||
status "==========================="
|
||||
npm list webpack
|
||||
npm run build
|
||||
status "==========================="
|
||||
fi
|
||||
|
||||
# Generate the plugin zip file.
|
||||
status "Creating archive... 🎁"
|
||||
|
|
|
@ -52,6 +52,11 @@ You can read more about legacy builds in the [this doc](./assets/js/legacy/READM
|
|||
|
||||
Run `$ npm run package-plugin` to trigger install and build, and then create a zip file which you can use to install WooCommerce Blocks in WordPress admin.
|
||||
|
||||
You can also do different variations of this command. By default it builds a production version of the plugin. You can also:
|
||||
|
||||
- Build a development version of the plugin: `$ npm run package-plugin:dev`
|
||||
- Just do a zip build of the current environment (useful when you already have built files for zipping): `$ npm run package-plugin:zip_only`
|
||||
|
||||
## Linting
|
||||
|
||||
Run `$ npm run lint` to check code against our linting rules.
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
|
||||
"build:ci": "npm run build && npm run size-check && npm run lint:js && npm run lint:css",
|
||||
"build:e2e-test": "npm run build",
|
||||
"dev": "cross-env BABEL_ENV=default webpack",
|
||||
"docker:up": "docker-compose up -d",
|
||||
"docker:up:build": "docker-compose up --build -d",
|
||||
"docker:down": "docker-compose down",
|
||||
|
@ -41,6 +42,8 @@
|
|||
"lint:js": "wp-scripts lint-js",
|
||||
"lint:js-fix": "eslint assets/js --ext=js,jsx --fix",
|
||||
"package-plugin": "./bin/build-plugin-zip.sh",
|
||||
"package-plugin:dev": "./bin/build-plugin-zip.sh -d",
|
||||
"package-plugin:zip-only": "./bin/build-plugin-zip.sh -z",
|
||||
"reformat-files": "prettier --ignore-path .eslintignore --write \"**/*.{js,jsx,json,ts,tsx}\"",
|
||||
"test": "wp-scripts test-unit-js --config tests/js/jest.config.json",
|
||||
"test:help": "wp-scripts test-unit-js --help",
|
||||
|
|
Loading…
Reference in New Issue