]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Analyze embed too with bundlewatch
authorChocobozzz <me@florianbigard.com>
Thu, 6 Aug 2020 08:26:39 +0000 (10:26 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Thu, 6 Aug 2020 08:58:36 +0000 (10:58 +0200)
.github/workflows/bundlewatch.yml
client/webpack/webpack.video-embed.js
package.json
scripts/build/client.sh
scripts/build/embed.sh
scripts/client-report.sh

index 312bf6e64a220432eaaecea989777a58ebc6e2ce..2ca854509197c25796b7a637f56825d3b5d4f9a5 100644 (file)
@@ -9,9 +9,12 @@ on:
 
 jobs:
 
-  test:
+  bundlewatch:
     runs-on: ubuntu-latest
 
+    env:
+      CI_BRANCH_BASE: develop
+
     steps:
       - uses: actions/checkout@v2
 
index 252040bb7df7a888e7472120e9d930c3bc13639f..e7671d3ea1a31842e171d720401d0d29f7c9c6ff 100644 (file)
@@ -33,9 +33,13 @@ module.exports = function () {
 
     output: {
       path: helpers.root('dist/standalone/videos'),
-      filename: '[name].[hash].bundle.js',
+
+      filename: process.env.ANALYZE_BUNDLE === 'true'
+        ? '[name].bundle.js'
+        : '[name].[hash].bundle.js',
+
       sourceMapFilename: '[file].map',
-      chunkFilename: '[id].chunk.js',
+      chunkFilename: '[id].[hash].chunk.js',
       publicPath: '/client/standalone/videos/'
     },
 
@@ -113,7 +117,9 @@ module.exports = function () {
 
     plugins: [
       new ExtractTextPlugin({
-        filename: '[name].[hash].css'
+        filename: process.env.ANALYZE_BUNDLE === 'true'
+          ? '[name].css'
+          : '[name].[hash].css'
       }),
 
       new PurifyCSSPlugin({
index aee13e79ff937633a55ab2ff22507400288c5287..4e4e58878cde8331009962351cbf54e3d9fd6c87 100644 (file)
       {
         "path": "client/dist/en-US/*-es2015.js",
         "maxSize": "1mb"
+      },
+      {
+        "path": "client/dist/standalone/videos/video-embed.bundle.js",
+        "maxSize": "1mb"
+      },
+      {
+        "path": "client/dist/standalone/videos/video-embed.css",
+        "maxSize": "1mb"
       }
     ]
   }
index 254ca4364b1d562ac50c1e1e5fe5f8029c7c0fa3..878de60df0169e07f464bf37707df734e991a6b1 100755 (executable)
@@ -33,6 +33,7 @@ pre_build_hook
 additionalParams=""
 if [ ! -z ${1+x} ] && [ "$1" == "--analyze-bundle" ]; then
     additionalParams="--namedChunks=true --outputHashing=none"
+    export ANALYZE_BUNDLE=true
 fi
 
 
@@ -154,9 +155,7 @@ if [ -z ${1+x} ] || ([ "$1" != "--light" ] && [ "$1" != "--analyze-bundle" ]); t
     done
 fi
 
-if [ ! -z ${1+x} ] || [ "$1" == "--analyze-bundle" ]; then
-    cd ../ && npm run build:embed && cd client/
-fi
+cd ../ && npm run build:embed && cd client/
 
 # Copy runtime locales
 cp -r "./src/locale" "./dist/locale"
index 4be2afc25d68364ca6d6fc26a419a8276fa0a6f1..3fcfc6ba2ef0f9ac4fbf1430f66dfd791faa8718 100755 (executable)
@@ -4,4 +4,5 @@ set -eu
 
 cd client
 
-NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json"
+mkdir -p ./dist/standalone/videos/
+NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/standalone/videos/embed-stats.json"
index 76609686b9188ba0bad0541c66e6786c09d3028b..f280fad2020c7a18de0acffc2013d92663772443 100755 (executable)
@@ -2,8 +2,8 @@
 
 set -eu
 
-gawk -i inplace 'BEGIN { found=0 } { if (found || $0 ~ /^{/) { found=1; print }}' ./client/dist/embed-stats.json
+gawk -i inplace 'BEGIN { found=0 } { if (found || $0 ~ /^{/) { found=1; print }}' ./client/dist/standalone/videos/embed-stats.json
 
 npm run concurrently -- -k \
     "cd client && npm run webpack-bundle-analyzer -- -p 8888 ./dist/en-US/stats-es2015.json" \
-    "cd client && npm run webpack-bundle-analyzer -- -p 8889 ./dist/embed-stats.json"
+    "cd client && npm run webpack-bundle-analyzer -- -p 8889 ./dist/standalone/videos/embed-stats.json"