From d3b1867c4afe25c5d263ea267b7b5d2c5d2084cf Mon Sep 17 00:00:00 2001 From: Stanislav Mishchyshyn Date: Wed, 10 Apr 2024 19:25:10 +0300 Subject: [PATCH] chore(ilc/client): better support for source maps on prod --- ilc/build/webpack.js | 8 ++++++-- ilc/package-lock.json | 4 +--- ilc/package.json | 1 + ilc/server/serveStatic.js | 5 ++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ilc/build/webpack.js b/ilc/build/webpack.js index fd6037ad..ec524664 100644 --- a/ilc/build/webpack.js +++ b/ilc/build/webpack.js @@ -1,7 +1,7 @@ /* eslint-env node */ const fs = require('fs'); const path = require('path'); -const { DefinePlugin } = require('webpack'); +const { DefinePlugin, SourceMapDevToolPlugin } = require('webpack'); const WrapperPlugin = require('wrapper-webpack-plugin'); const { DuplicateIlcPluginsWebpackPlugin, ResolveIlcDefaultPluginsWebpackPlugin } = require('ilc-plugins-sdk/webpack'); @@ -55,8 +55,12 @@ module.exports = { new DefinePlugin({ LEGACY_PLUGINS_DISCOVERY_ENABLED: JSON.stringify(environment.isLegacyPluginsDiscoveryEnabled()), }), + new SourceMapDevToolPlugin({ + append: '\n//# sourceMappingURL=http://localhost:8233/_ilc/[url]', + filename: '[file].map[query]', + }), ], - devtool: 'source-map', + devtool: false, externals: [], /** * Very slow performance on macos with webpack-dev-middleware diff --git a/ilc/package-lock.json b/ilc/package-lock.json index 3cf06cfc..7935e56c 100644 --- a/ilc/package-lock.json +++ b/ilc/package-lock.json @@ -17,6 +17,7 @@ "cidr-matcher": "^2.1.1", "config": "^3.3.9", "cookie": "^0.5.0", + "cors": "^2.8.5", "cross-env": "^7.0.3", "debug": "^4.3.4", "deepmerge": "4.3.1", @@ -5111,7 +5112,6 @@ "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dev": true, "dependencies": { "object-assign": "^4", "vary": "^1" @@ -9260,7 +9260,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -11983,7 +11982,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "dev": true, "engines": { "node": ">= 0.8" } diff --git a/ilc/package.json b/ilc/package.json index 990a919a..9fcb26de 100644 --- a/ilc/package.json +++ b/ilc/package.json @@ -29,6 +29,7 @@ "cidr-matcher": "^2.1.1", "config": "^3.3.9", "cookie": "^0.5.0", + "cors": "^2.8.5", "cross-env": "^7.0.3", "debug": "^4.3.4", "deepmerge": "4.3.1", diff --git a/ilc/server/serveStatic.js b/ilc/server/serveStatic.js index 6bf0158c..352d2164 100644 --- a/ilc/server/serveStatic.js +++ b/ilc/server/serveStatic.js @@ -1,6 +1,5 @@ -'use strict'; - const serveStatic = require('serve-static'); +const cors = require('cors'); module.exports = function (isProduction) { if (isProduction) { @@ -14,5 +13,5 @@ module.exports = function (isProduction) { const webpackConfig = require('../../build/webpack.dev'); const compiler = webpack(webpackConfig); - return [webpackDevMiddleware(compiler), serveStatic('public')]; + return [cors({ origin: true }), webpackDevMiddleware(compiler), serveStatic('public')]; };