From 0403fa9517d24cb4c8570ffaf9a5be9aafd436c4 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Jul 2020 20:54:33 -0700 Subject: [PATCH] Build fixes --- package.json | 5 ++-- webpack.config.js | 30 ++++++++++++---------- yarn.lock | 65 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 3614da244..5b28d349a 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "eslint-plugin-standard": "^4.0.1", "fork-ts-checker-webpack-plugin": "^5.0.6", "redux-devtools-extension": "^2.13.8", + "source-map-loader": "^1.0.1", "style-loader": "^1.2.1", "svg-url-loader": "^6.0.0", "tailwindcss": "^1.4.6", @@ -99,12 +100,12 @@ "yarn-deduplicate": "^1.1.1" }, "scripts": { - "clean": "rm -rf public/assets/*.{js,css,map}", + "clean": "cd public/assets && find . \\( -name \"*.js\" -o -name \"*.map\" \\) -type f -delete", "lint": "eslint ./resources/scripts/**/*.{ts,tsx} --ext .ts,.tsx", "watch": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --watch --progress", "build": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --progress", "build:production": "yarn run clean && cross-env NODE_ENV=production ./node_modules/.bin/webpack --mode production", - "serve": "yarn run clean && cross-env PUBLIC_PATH=https://pterodactyl.test:8080 cross-env TSC_WATCHFILE=UseFsEventsWithFallbackDynamicPolling NODE_ENV=development webpack-dev-server --host 0.0.0.0 --hot --https --key /etc/ssl/private/pterodactyl.test-key.pem --cert /etc/ssl/private/pterodactyl.test.pem" + "serve": "yarn run clean && cross-env PUBLIC_PATH=https://pterodactyl.test:8080 NODE_ENV=development TSC_WATCHFILE=UseFsEventsWithFallbackDynamicPolling webpack-dev-server --host 0.0.0.0 --hot --https --key /etc/ssl/private/pterodactyl.test-key.pem --cert /etc/ssl/private/pterodactyl.test.pem" }, "browserslist": [ "> 0.5%", diff --git a/webpack.config.js b/webpack.config.js index 780461bd7..2efa27154 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -10,14 +10,13 @@ module.exports = { cache: true, target: 'web', mode: process.env.NODE_ENV, - context: __dirname, devtool: isProduction ? false : (process.env.DEVTOOL || 'eval-source-map'), performance: { hints: false, }, entry: ['react-hot-loader/patch', './resources/scripts/index.tsx'], output: { - path: path.resolve(__dirname, '/public/assets'), + path: path.join(__dirname, '/public/assets'), filename: isProduction ? 'bundle.[chunkhash:8].js' : 'bundle.[hash:8].js', chunkFilename: isProduction ? '[name].[chunkhash:8].js' : '[name].[hash:8].js', publicPath: (process.env.PUBLIC_PATH || '') + '/assets/', @@ -26,7 +25,7 @@ module.exports = { module: { rules: [ { - test: /\.ts(x?)$/, + test: /\.tsx?$/, exclude: /node_modules/, loader: 'babel-loader', options: { @@ -38,27 +37,32 @@ module.exports = { use: [ 'style-loader', 'css-loader' ], }, { - test: /\.(png|jpe?g|gif)$/, + test: /\.(png|jp(e?)g|gif)$/, loader: 'file-loader', options: { - name: 'images/[name].[hash].[ext]', + name: 'images/[name].[hash:8].[ext]', }, }, { test: /\.svg$/, loader: 'svg-url-loader', + }, + { + test: /\.js$/, + enforce: 'pre', + loader: 'source-map-loader', } - // { - // enforce: 'pre', - // test: /\.js$/, - // loader: 'source-map-loader', - // }, ], }, + stats: { + // Ignore warnings emitted by "source-map-loader" when trying to parse source maps from + // JS plugins we use, namely brace editor. + warningsFilter: [/Failed to parse source map/], + }, resolve: { extensions: ['.ts', '.tsx', '.js', '.json'], alias: { - '@': path.resolve(__dirname, 'resources/scripts'), + '@': path.join(__dirname, '/resources/scripts'), }, symlinks: false, }, @@ -66,7 +70,7 @@ module.exports = { new AssetsManifestPlugin({ writeToDisk: true, publicPath: true, integrity: true, integrityHashes: ['sha384'] }), !isProduction ? new ForkTsCheckerWebpackPlugin({ eslint: { - files: './resources/scripts/**/*.{ts,tsx}', + files: `${path.join(__dirname, '/resources/scripts')}/**/*.{ts,tsx}`, }, }) : null, process.env.ANALYZE_BUNDLE ? new BundleAnalyzerPlugin() : null @@ -97,7 +101,7 @@ module.exports = { }, devServer: { compress: true, - contentBase: 'public', + contentBase: path.join(__dirname, '/public'), publicPath: (process.env.PUBLIC_PATH || '') + '/assets/', allowedHosts: [ '.pterodactyl.test', diff --git a/yarn.lock b/yarn.lock index 1f46e2f7b..272d5b83f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1322,6 +1322,11 @@ version "1.1.0" resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" +abab@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a" + integrity sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg== + abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" @@ -2385,6 +2390,15 @@ cyclist@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" +data-urls@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b" + integrity sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ== + dependencies: + abab "^2.0.3" + whatwg-mimetype "^2.3.0" + whatwg-url "^8.0.0" + date-fns@^2.14.0: version "2.14.0" resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba" @@ -3776,6 +3790,13 @@ iconv-lite@0.4.24, iconv-lite@^0.4.4: dependencies: safer-buffer ">= 2.1.2 < 3" +iconv-lite@^0.5.1: + version "0.5.2" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.5.2.tgz#af6d628dccfb463b7364d97f715e4b74b8c8c2b8" + integrity sha512-kERHXvpSaB4aU3eANwidg79K8FlrN77m8G9V+0vOR3HYaRifrlwMEpT7ZBJqLSEIHnEgJTHcWK82wwLwwKwtag== + dependencies: + safer-buffer ">= 2.1.2 < 3" + icss-utils@^4.0.0, icss-utils@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467" @@ -4351,6 +4372,11 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= + lodash.toarray@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561" @@ -5442,7 +5468,7 @@ punycode@^1.2.4: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -punycode@^2.1.0: +punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -6179,6 +6205,17 @@ source-list-map@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" +source-map-loader@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-1.0.1.tgz#703df5345b0816734f0336c1ccee8af66e082061" + integrity sha512-DE4CJyfCVoxFLsHyuVE9Sjcib8cs5qdmOq3wcev1Un/r6F2AfQJDhag4rzpPPA48A2QZyV3CTbc+NGoFMfKIOQ== + dependencies: + data-urls "^2.0.0" + iconv-lite "^0.5.1" + loader-utils "^2.0.0" + schema-utils "^2.6.6" + source-map "^0.6.0" + source-map-resolve@^0.5.0: version "0.5.2" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259" @@ -6691,6 +6728,13 @@ toposort@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" +tr46@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.0.2.tgz#03273586def1595ae08fedb38d7733cee91d2479" + integrity sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg== + dependencies: + punycode "^2.1.1" + tryer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" @@ -6974,6 +7018,11 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" +webidl-conversions@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" + integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== + webpack-assets-manifest@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/webpack-assets-manifest/-/webpack-assets-manifest-3.1.1.tgz#39bbc3bf2ee57fcd8ba07cda51c9ba4a3c6ae1de" @@ -7133,6 +7182,20 @@ websocket-extensions@>=0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" +whatwg-mimetype@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" + integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== + +whatwg-url@^8.0.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.1.0.tgz#c628acdcf45b82274ce7281ee31dd3c839791771" + integrity sha512-vEIkwNi9Hqt4TV9RdnaBPNt+E2Sgmo3gePebCRgZ1R7g6d23+53zCTnuB0amKI4AXq6VM8jj2DUAa0S1vjJxkw== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^2.0.2" + webidl-conversions "^5.0.0" + which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"