mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow adding additional webpack externals at build time (#6883)
Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a482fc57e0
commit
661546eba4
@ -12,7 +12,7 @@ import CircularDependencyPlugin from "circular-dependency-plugin";
|
|||||||
import { iconsAndImagesWebpackRules } from "./renderer";
|
import { iconsAndImagesWebpackRules } from "./renderer";
|
||||||
import type { WebpackPluginInstance } from "webpack";
|
import type { WebpackPluginInstance } from "webpack";
|
||||||
import { DefinePlugin } from "webpack";
|
import { DefinePlugin } from "webpack";
|
||||||
import { buildDir, isDevelopment, mainDir } from "./vars";
|
import { additionalExternals, buildDir, isDevelopment, mainDir } from "./vars";
|
||||||
import { platform } from "process";
|
import { platform } from "process";
|
||||||
|
|
||||||
const main = ({ showVars = true } = {}): webpack.Configuration => {
|
const main = ({ showVars = true } = {}): webpack.Configuration => {
|
||||||
@ -43,6 +43,7 @@ const main = ({ showVars = true } = {}): webpack.Configuration => {
|
|||||||
},
|
},
|
||||||
externals: [
|
externals: [
|
||||||
nodeExternals(),
|
nodeExternals(),
|
||||||
|
...additionalExternals,
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
parser: {
|
parser: {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
|
|||||||
import type { WebpackPluginInstance } from "webpack";
|
import type { WebpackPluginInstance } from "webpack";
|
||||||
import { DefinePlugin } from "webpack";
|
import { DefinePlugin } from "webpack";
|
||||||
import getTypescriptLoader from "./get-typescript-loader";
|
import getTypescriptLoader from "./get-typescript-loader";
|
||||||
import { assetsFolderName, isDevelopment, rendererDir, buildDir, appName, htmlTemplate, publicPath, sassCommonVars } from "./vars";
|
import { assetsFolderName, isDevelopment, rendererDir, buildDir, appName, htmlTemplate, publicPath, sassCommonVars, additionalExternals } from "./vars";
|
||||||
import { platform } from "process";
|
import { platform } from "process";
|
||||||
|
|
||||||
export function webpackLensRenderer({ showVars = true } = {}): webpack.Configuration {
|
export function webpackLensRenderer({ showVars = true } = {}): webpack.Configuration {
|
||||||
@ -63,9 +63,12 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
|
|||||||
".ts", ".tsx",
|
".ts", ".tsx",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
externals: {
|
externals: [
|
||||||
"node-fetch": "commonjs node-fetch",
|
{
|
||||||
},
|
"node-fetch": "commonjs node-fetch",
|
||||||
|
},
|
||||||
|
...additionalExternals,
|
||||||
|
],
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: false,
|
minimize: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -21,5 +21,8 @@ export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
|||||||
export const publicPath = "/build/";
|
export const publicPath = "/build/";
|
||||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||||
export const webpackDevServerPort = Number(process.env.WEBPACK_DEV_SERVER_PORT) || 9191;
|
export const webpackDevServerPort = Number(process.env.WEBPACK_DEV_SERVER_PORT) || 9191;
|
||||||
|
export const additionalExternals = (process.env.LENS_BUILD_ADDITIONAL_WEBPACK_EXTERNALS || "")
|
||||||
|
.split(",")
|
||||||
|
.map(s => s.trim());
|
||||||
|
|
||||||
assert(Number.isInteger(webpackDevServerPort), "WEBPACK_DEV_SERVER_PORT environment variable must only be an integer");
|
assert(Number.isInteger(webpackDevServerPort), "WEBPACK_DEV_SERVER_PORT environment variable must only be an integer");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user