diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..3ac86e339 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#!/bin/sh +TARGET="${TARGET:-../pleroma}" # Where pleroma’s repository is sitting +static_dir="priv/static" # Set this to instance/static when testing production build + +if [[ ! -d "${TARGET}/${static_dir}" ]] +then + echo "Error: ${TARGET}/${static_dir} directory is missing, are you sure TARGET is set to a pleroma repository?" + echo "Info: TARGET=${TARGET}" + exit 1 +fi + +yarn install -D + +rm -rf public/packs public/assets +env -i "PATH=$PATH" npm run build +cp public/assets/sw.js "${TARGET}/${static_dir}/sw.js" +rm -rf "${TARGET}/${static_dir}/packs" +cp -r public/packs "${TARGET}/${static_dir}/packs" +rm -rf "${TARGET}/${static_dir}/emoji/*.svg" +cp -r public/emoji/* "${TARGET}/${static_dir}/emoji" diff --git a/config/webpack/development.js b/config/webpack/development.js index 1e50a4f46..6cbca7a4a 100644 --- a/config/webpack/development.js +++ b/config/webpack/development.js @@ -23,6 +23,8 @@ module.exports = merge(sharedConfig, { }, output: { + filename: '[name].js', + chunkFilename: '[name].js', pathinfo: true, }, diff --git a/config/webpack/production.js b/config/webpack/production.js index c829ff6f1..24022e924 100644 --- a/config/webpack/production.js +++ b/config/webpack/production.js @@ -3,10 +3,8 @@ const path = require('path'); const { URL } = require('url'); const merge = require('webpack-merge'); -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); const OfflinePlugin = require('offline-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); -const CompressionPlugin = require('compression-webpack-plugin'); const { output } = require('./configuration'); const sharedConfig = require('./shared'); @@ -27,6 +25,10 @@ if (process.env.S3_ENABLED === 'true') { module.exports = merge(sharedConfig, { mode: 'production', + output: { + filename: '[name].js', + chunkFilename: '[name].js', + }, devtool: 'source-map', stats: 'normal', bail: true, @@ -52,16 +54,6 @@ module.exports = merge(sharedConfig, { }, plugins: [ - new CompressionPlugin({ - filename: '[path].gz[query]', - cache: true, - test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/, - }), - new BundleAnalyzerPlugin({ // generates report.html - analyzerMode: 'static', - openAnalyzer: false, - logLevel: 'silent', // do not bother Webpacker, who runs with --json and parses stdout - }), new OfflinePlugin({ publicPath: output.publicPath, // sw.js must be served from the root to avoid scope issues caches: { @@ -85,7 +77,6 @@ module.exports = merge(sharedConfig, { '/emoji/sheet_10.png', // used in emoji-mart ], excludes: [ - '**/*.gz', '**/*.map', 'stats.json', 'report.html', diff --git a/config/webpack/shared.js b/config/webpack/shared.js index b6e2537b1..a6ed126d9 100644 --- a/config/webpack/shared.js +++ b/config/webpack/shared.js @@ -100,8 +100,7 @@ module.exports = { } ), new MiniCssExtractPlugin({ - filename: 'css/[name]-[contenthash:8].css', - chunkFilename: 'css/[name]-[contenthash:8].chunk.css', + filename: '[name].css', }), new AssetsManifestPlugin({ integrity: false, diff --git a/package.json b/package.json index 635dc3f8a..97efa16dd 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,6 @@ "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "babel-runtime": "^6.26.0", "classnames": "^2.2.5", - "compression-webpack-plugin": "^2.0.0", "cross-env": "^5.1.4", "css-loader": "^2.1.1", "cssnano": "^4.1.10", @@ -164,7 +163,6 @@ "uws": "10.148.0", "webpack": "^4.29.6", "webpack-assets-manifest": "^3.1.1", - "webpack-bundle-analyzer": "^3.1.0", "webpack-cli": "^3.2.3", "webpack-merge": "^4.2.1", "websocket.js": "^0.1.12" diff --git a/yarn.lock b/yarn.lock index 11fe49fa6..871b133a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1240,7 +1240,7 @@ acorn-jsx@^5.0.0: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.1.tgz#32a064fd925429216a09b141102bfdd185fae40e" integrity sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg== -acorn-walk@^6.0.1, acorn-walk@^6.1.1: +acorn-walk@^6.0.1: version "6.1.1" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.1.1.tgz#d363b66f5fac5f018ff9c3a1e7b6f8e310cc3913" integrity sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw== @@ -1255,7 +1255,7 @@ acorn@^6.0.1, acorn@^6.0.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.4.tgz#77377e7353b72ec5104550aa2d2097a2fd40b754" integrity sha512-VY4i5EKSKkofY2I+6QLTbTTN/UvEQPCo6eiwzzSaSWfpaDhOmStMCMod6wmuPciNq+XS0faCglFu2lHZpdHUtg== -acorn@^6.0.5, acorn@^6.0.7: +acorn@^6.0.5: version "6.1.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f" integrity sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA== @@ -1717,16 +1717,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -bfj@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.1.tgz#05a3b7784fbd72cfa3c22e56002ef99336516c48" - integrity sha512-+GUNvzHR4nRyGybQc2WpNJL4MJazMuvf92ueIyA0bIkPRwhhQu3IfZQ2PSoVPpCBJfmoSdOxu5rnotfFLlvYRQ== - dependencies: - bluebird "^3.5.1" - check-types "^7.3.0" - hoopy "^0.1.2" - tryer "^1.0.0" - big.js@^3.1.3: version "3.2.0" resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" @@ -1742,7 +1732,7 @@ binary-extensions@^1.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14" integrity sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg== -bluebird@^3.5.1, bluebird@^3.5.3: +bluebird@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw== @@ -2113,11 +2103,6 @@ chardet@^0.7.0: resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== -check-types@^7.3.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/check-types/-/check-types-7.4.0.tgz#0378ec1b9616ec71f774931a3c6516fad8c152f4" - integrity sha512-YbulWHdfP99UfZ73NcUDlNJhEIDgm9Doq9GhpyXbF+7Aegi3CVV7qqMCKTTqJxlvEvnQBp9IA+dxsGN6xK/nSg== - cheerio@^1.0.0-rc.2: version "1.0.0-rc.2" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.2.tgz#4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db" @@ -2298,7 +2283,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^2.11.0, commander@^2.18.0, commander@^2.19.0: +commander@^2.11.0, commander@^2.19.0: version "2.19.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== @@ -2330,18 +2315,6 @@ compressible@~2.0.14: dependencies: mime-db ">= 1.36.0 < 2" -compression-webpack-plugin@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-2.0.0.tgz#46476350c1eb27f783dccc79ac2f709baa2cffbc" - integrity sha512-bDgd7oTUZC8EkRx8j0sjyCfeiO+e5sFcfgaFcjVhfQf5lLya7oY2BczxcJ7IUuVjz5m6fy8IECFmVFew3xLk8Q== - dependencies: - cacache "^11.2.0" - find-cache-dir "^2.0.0" - neo-async "^2.5.0" - schema-utils "^1.0.0" - serialize-javascript "^1.4.0" - webpack-sources "^1.0.1" - compression@^1.5.2: version "1.7.3" resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.3.tgz#27e0e176aaf260f7f2c2813c3e440adb9f1993db" @@ -3121,11 +3094,6 @@ double-ended-queue@^2.1.0-0: resolved "https://registry.yarnpkg.com/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz#103d3527fd31528f40188130c841efdd78264e5c" integrity sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw= -duplexer@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" - integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E= - duplexify@^3.4.2, duplexify@^3.6.0: version "3.6.1" resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.6.1.tgz#b1a7a29c4abfd639585efaecce80d666b1e34125" @@ -3149,7 +3117,7 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= -ejs@^2.3.4, ejs@^2.6.1: +ejs@^2.3.4: version "2.6.1" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.6.1.tgz#498ec0d495655abc6f23cd61868d926464071aa0" integrity sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ== @@ -3620,7 +3588,7 @@ expect@^24.5.0: jest-message-util "^24.5.0" jest-regex-util "^24.3.0" -express@^4.16.2, express@^4.16.3, express@^4.16.4: +express@^4.16.2, express@^4.16.4: version "4.16.4" resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e" integrity sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg== @@ -3805,11 +3773,6 @@ fileset@^2.0.3: glob "^7.0.3" minimatch "^3.0.3" -filesize@^3.6.1: - version "3.6.1" - resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.6.1.tgz#090bb3ee01b6f801a8a8be99d31710b3422bb317" - integrity sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg== - fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -4118,14 +4081,6 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -gzip-size@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.0.0.tgz#a55ecd99222f4c48fd8c01c625ce3b349d0a0e80" - integrity sha512-5iI7omclyqrnWw4XbXAmGhPsABkSIDQonv2K0h61lybgofWa6iZyvrI3r2zsJH4P8Nb64fFVzlvfhs0g7BBxAA== - dependencies: - duplexer "^0.1.1" - pify "^3.0.0" - handle-thing@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.0.tgz#0e039695ff50c93fc288557d696f3c1dc6776754" @@ -4280,11 +4235,6 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" -hoopy@^0.1.2: - version "0.1.4" - resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d" - integrity sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ== - hosted-git-info@^2.1.4: version "2.7.1" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" @@ -6438,11 +6388,6 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -opener@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed" - integrity sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA== - opn@^5.1.0: version "5.4.0" resolved "https://registry.yarnpkg.com/opn/-/opn-5.4.0.tgz#cb545e7aab78562beb11aa3bfabc7042e1761035" @@ -9043,11 +8988,6 @@ trim-right@^1.0.1: resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= -tryer@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" - integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== - tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" @@ -9383,25 +9323,6 @@ webpack-assets-manifest@^3.1.1: tapable "^1.0.0" webpack-sources "^1.0.0" -webpack-bundle-analyzer@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.1.0.tgz#2f19cbb87bb6d4f3cb4e59cb67c837bd9436e89d" - integrity sha512-nyDyWEs7C6DZlgvu1pR1zzJfIWSiGPbtaByZr8q+Fd2xp70FuM/8ngCJzj3Er1TYRLSFmp1F1OInbEm4DZH8NA== - dependencies: - acorn "^6.0.7" - acorn-walk "^6.1.1" - bfj "^6.1.1" - chalk "^2.4.1" - commander "^2.18.0" - ejs "^2.6.1" - express "^4.16.3" - filesize "^3.6.1" - gzip-size "^5.0.0" - lodash "^4.17.10" - mkdirp "^0.5.1" - opener "^1.5.1" - ws "^6.0.0" - webpack-cli@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.2.3.tgz#13653549adfd8ccd920ad7be1ef868bacc22e346" @@ -9480,7 +9401,7 @@ webpack-merge@^4.2.1: dependencies: lodash "^4.17.5" -webpack-sources@^1.0.0, webpack-sources@^1.0.1, webpack-sources@^1.1.0, webpack-sources@^1.3.0: +webpack-sources@^1.0.0, webpack-sources@^1.1.0, webpack-sources@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.3.0.tgz#2a28dcb9f1f45fe960d8f1493252b5ee6530fa85" integrity sha512-OiVgSrbGu7NEnEvQJJgdSFPl2qWKkWq5lHMhgiToIiN9w34EBnjYzSYs+VbL5KoYiLNtFFa7BZIKxRED3I32pA== @@ -9645,13 +9566,6 @@ ws@^5.2.0: dependencies: async-limiter "~1.0.0" -ws@^6.0.0: - version "6.1.2" - resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.2.tgz#3cc7462e98792f0ac679424148903ded3b9c3ad8" - integrity sha512-rfUqzvz0WxmSXtJpPMX2EeASXabOrSMk1ruMOV3JBTBjo4ac2lDjGGsbQSyxj8Odhw5fBib8ZKEjDNvgouNKYw== - dependencies: - async-limiter "~1.0.0" - xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"