diff --git a/.github/workflows/bundlewatch.yml b/.github/workflows/bundlewatch.yml new file mode 100644 index 000000000..94536c74e --- /dev/null +++ b/.github/workflows/bundlewatch.yml @@ -0,0 +1,40 @@ +name: "Bundlewatch Github Action" + +on: + push: + branches: + - develop + pull_request: + types: [synchronize, opened] + +jobs: + + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Cache Node.js modules + uses: actions/cache@v2 + with: + path: | + **/node_modules + ~/fixtures + key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-node- + ${{ runner.OS }}- + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - uses: jackyef/bundlewatch-gh-action@master + with: + build-script: npm run build -- --analyze-bundle + bundlewatch-github-token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/package.json b/package.json index c579030f5..aee13e79f 100644 --- a/package.json +++ b/package.json @@ -218,5 +218,13 @@ "sasslintConfig": "client/.sass-lint.yml", "_moduleAliases": { "@server": "dist/server" + }, + "bundlewatch" : { + "files": [ + { + "path": "client/dist/en-US/*-es2015.js", + "maxSize": "1mb" + } + ] } } diff --git a/scripts/build/client.sh b/scripts/build/client.sh index a9eceebf9..75da6765c 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh @@ -30,15 +30,21 @@ rm -rf ./dist ./compiled pre_build_hook +additionalParams="" +if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then + additionalParams="--namedChunks=true --outputHashing=none" +fi + + defaultLanguage="en-US" -npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json +npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json $additionalParams mv "./dist/$defaultLanguage/assets" "./dist" mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest" post_build_hook # Don't build other languages if --light arg is provided -if [ -z ${1+x} ] || [ "$1" != "--light" ]; then +if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); then if [ ! -z ${1+x} ] && [ "$1" == "--light-hu" ]; then languages=(["hu"]="hu-HU") elif [ ! -z ${1+x} ] && [ "$1" == "--light-ar" ]; then