mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
removing webpack-dev-server, clean up
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
398af8cc07
commit
faaa8034c9
@ -17,7 +17,7 @@
|
|||||||
"debug-build": "concurrently yarn:compile:main yarn:compile:extension-types",
|
"debug-build": "concurrently yarn:compile:main yarn:compile:extension-types",
|
||||||
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --remote-debugging-port=9223 --inspect .\"",
|
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --remote-debugging-port=9223 --inspect .\"",
|
||||||
"dev:main": "yarn run compile:main --watch --progress",
|
"dev:main": "yarn run compile:main --watch --progress",
|
||||||
"dev:renderer": "yarn run webpack-dev-server --config webpack.renderer.ts --progress",
|
"dev:renderer": "yarn run compile:renderer --watch --progress",
|
||||||
"dev:extension-types": "yarn run compile:extension-types --watch --progress",
|
"dev:extension-types": "yarn run compile:extension-types --watch --progress",
|
||||||
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
|
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
|
||||||
"compile:main": "yarn run webpack --config webpack.main.ts",
|
"compile:main": "yarn run webpack --config webpack.main.ts",
|
||||||
@ -318,7 +318,6 @@
|
|||||||
"@types/url-parse": "^1.4.5",
|
"@types/url-parse": "^1.4.5",
|
||||||
"@types/uuid": "^8.3.3",
|
"@types/uuid": "^8.3.3",
|
||||||
"@types/webpack": "^5.28.0",
|
"@types/webpack": "^5.28.0",
|
||||||
"@types/webpack-dev-server": "^4.7.2",
|
|
||||||
"@types/webpack-env": "^1.16.3",
|
"@types/webpack-env": "^1.16.3",
|
||||||
"@types/webpack-node-externals": "^2.5.3",
|
"@types/webpack-node-externals": "^2.5.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
||||||
@ -384,7 +383,6 @@
|
|||||||
"typescript-plugin-css-modules": "^3.4.0",
|
"typescript-plugin-css-modules": "^3.4.0",
|
||||||
"webpack": "^5.67.0",
|
"webpack": "^5.67.0",
|
||||||
"webpack-cli": "^4.9.1",
|
"webpack-cli": "^4.9.1",
|
||||||
"webpack-dev-server": "^4.7.3",
|
|
||||||
"webpack-node-externals": "^3.0.0",
|
"webpack-node-externals": "^3.0.0",
|
||||||
"xterm": "^4.15.0",
|
"xterm": "^4.15.0",
|
||||||
"xterm-addon-fit": "^0.5.0"
|
"xterm-addon-fit": "^0.5.0"
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import type { Options as TSLoaderOptions } from "ts-loader";
|
|||||||
*/
|
*/
|
||||||
const getTSLoader = (options: Partial<TSLoaderOptions> = {}, testRegExp?: RegExp) => {
|
const getTSLoader = (options: Partial<TSLoaderOptions> = {}, testRegExp?: RegExp) => {
|
||||||
testRegExp ??= /\.tsx?$/; // by default covers react/jsx-stuff
|
testRegExp ??= /\.tsx?$/; // by default covers react/jsx-stuff
|
||||||
options.transpileOnly ??= true; // requirement for "react-refresh-typescript"
|
options.transpileOnly ??= true;
|
||||||
|
|
||||||
if (process.env.LENS_DEV_USE_ESBUILD_LOADER === "true") {
|
if (process.env.LENS_DEV_USE_ESBUILD_LOADER === "true") {
|
||||||
console.info(`\n🚀 using esbuild-loader for ts(x)`);
|
console.info(`\n🚀 using esbuild-loader for ts(x)`);
|
||||||
|
|||||||
@ -38,7 +38,6 @@ export const mainDir = path.join(contextDir, "src/main");
|
|||||||
export const rendererDir = path.join(contextDir, "src/renderer");
|
export const rendererDir = path.join(contextDir, "src/renderer");
|
||||||
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||||
export const webpackDevServerPort = 9009;
|
|
||||||
|
|
||||||
// Special runtime paths
|
// Special runtime paths
|
||||||
defineGlobal("__static", {
|
defineGlobal("__static", {
|
||||||
|
|||||||
@ -9,13 +9,7 @@ import type http from "http";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { readFile } from "fs-extra";
|
import { readFile } from "fs-extra";
|
||||||
import type { Cluster } from "../common/cluster/cluster";
|
import type { Cluster } from "../common/cluster/cluster";
|
||||||
import {
|
import { apiPrefix, appName, publicPath } from "../common/vars";
|
||||||
apiPrefix,
|
|
||||||
appName,
|
|
||||||
isDevelopment,
|
|
||||||
publicPath,
|
|
||||||
webpackDevServerPort,
|
|
||||||
} from "../common/vars";
|
|
||||||
import {
|
import {
|
||||||
HelmApiRoute,
|
HelmApiRoute,
|
||||||
KubeconfigRoute,
|
KubeconfigRoute,
|
||||||
@ -147,26 +141,6 @@ export class Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// redirect requests to [appName].js, [appName].html /sockjs-node/ to webpack-dev-server (for hot-reload support)
|
|
||||||
const filename = path.basename(req.url);
|
|
||||||
const toWebpackDevServer = filename.includes(appName) || filename.includes("hot-update") || req.url.includes("sockjs-node");
|
|
||||||
|
|
||||||
if (isDevelopment) {
|
|
||||||
logger.info(`[ROUTER]: handling request`, {
|
|
||||||
url: req.url,
|
|
||||||
toWebpackDevServer,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (toWebpackDevServer) {
|
|
||||||
const redirectLocation = `http://localhost:${webpackDevServerPort}${req.url}`;
|
|
||||||
|
|
||||||
response.statusCode = 307;
|
|
||||||
response.setHeader("Location", redirectLocation);
|
|
||||||
|
|
||||||
return response.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await readFile(asset);
|
const data = await readFile(asset);
|
||||||
|
|
||||||
response.setHeader("Content-Type", getMimeType(asset));
|
response.setHeader("Content-Type", getMimeType(asset));
|
||||||
|
|||||||
@ -15,13 +15,13 @@ const configs: { (): webpack.Configuration }[] = [];
|
|||||||
|
|
||||||
configs.push((): webpack.Configuration => {
|
configs.push((): webpack.Configuration => {
|
||||||
console.info("WEBPACK:main", vars);
|
console.info("WEBPACK:main", vars);
|
||||||
const { isProduction, mainDir, buildDir, isDevelopment } = vars;
|
const { mainDir, buildDir, isDevelopment } = vars;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
target: "electron-main",
|
target: "electron-main",
|
||||||
mode: isProduction ? "production" : "development",
|
mode: isDevelopment ? "development" : "production",
|
||||||
devtool: isDevelopment ? "eval-cheap-module-source-map" : "source-map",
|
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
|
||||||
cache: isDevelopment,
|
cache: isDevelopment,
|
||||||
entry: {
|
entry: {
|
||||||
main: path.resolve(mainDir, "index.ts"),
|
main: path.resolve(mainDir, "index.ts"),
|
||||||
|
|||||||
@ -21,34 +21,16 @@ export function webpackLensRenderer(): webpack.Configuration {
|
|||||||
buildDir,
|
buildDir,
|
||||||
htmlTemplate,
|
htmlTemplate,
|
||||||
isDevelopment,
|
isDevelopment,
|
||||||
isProduction,
|
|
||||||
publicPath,
|
publicPath,
|
||||||
rendererDir,
|
rendererDir,
|
||||||
webpackDevServerPort,
|
|
||||||
} = vars;
|
} = vars;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
target: "electron-renderer",
|
target: "electron-renderer",
|
||||||
devtool: isDevelopment ? "eval-cheap-module-source-map" : "source-map",
|
|
||||||
// @ts-ignore: seems like types from "webpack-dev-server@4.7" not properly merged with "webpack@5"
|
|
||||||
// API: https://webpack.js.org/configuration/dev-server/#usage-via-api
|
|
||||||
devServer: {
|
|
||||||
headers: {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
},
|
|
||||||
allowedHosts: "all",
|
|
||||||
host: "localhost",
|
|
||||||
port: webpackDevServerPort,
|
|
||||||
static: buildDir, // aka `devServer.contentBase` in webpack@4
|
|
||||||
hot: true,
|
|
||||||
client: {
|
|
||||||
overlay: false, // don't show warnings and errors on top of rendered app view
|
|
||||||
logging: isDevelopment ? "verbose" : "error",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
name: "lens-app",
|
name: "lens-app",
|
||||||
mode: isProduction ? "production" : "development",
|
mode: isDevelopment ? "development" : "production",
|
||||||
|
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
|
||||||
cache: isDevelopment,
|
cache: isDevelopment,
|
||||||
entry: {
|
entry: {
|
||||||
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
||||||
@ -62,12 +44,10 @@ export function webpackLensRenderer(): webpack.Configuration {
|
|||||||
chunkFilename: "chunks/[name].js",
|
chunkFilename: "chunks/[name].js",
|
||||||
assetModuleFilename: "assets/[name][ext][query]",
|
assetModuleFilename: "assets/[name][ext][query]",
|
||||||
},
|
},
|
||||||
stats: {
|
ignoreWarnings: [
|
||||||
warningsFilter: [
|
|
||||||
/Critical dependency: the request of a dependency is an expression/,
|
/Critical dependency: the request of a dependency is an expression/,
|
||||||
/export '.*' was not found in/,
|
/export '.*' was not found in/,
|
||||||
],
|
],
|
||||||
},
|
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [
|
extensions: [
|
||||||
".js", ".jsx", ".json",
|
".js", ".jsx", ".json",
|
||||||
@ -114,6 +94,7 @@ export function webpackLensRenderer(): webpack.Configuration {
|
|||||||
filename: `${appName}.html`,
|
filename: `${appName}.html`,
|
||||||
template: htmlTemplate,
|
template: htmlTemplate,
|
||||||
inject: true,
|
inject: true,
|
||||||
|
hash: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new CircularDependencyPlugin({
|
new CircularDependencyPlugin({
|
||||||
@ -157,7 +138,7 @@ export function cssModulesWebpackRule(
|
|||||||
{
|
{
|
||||||
styleLoader = vars.isDevelopment ? "style-loader" : MiniCssExtractPlugin.loader,
|
styleLoader = vars.isDevelopment ? "style-loader" : MiniCssExtractPlugin.loader,
|
||||||
} = {}): webpack.RuleSetRule {
|
} = {}): webpack.RuleSetRule {
|
||||||
const { isDevelopment, sassCommonVars } = vars;
|
const { /*isDevelopment,*/ sassCommonVars } = vars;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
test: /\.s?css$/,
|
test: /\.s?css$/,
|
||||||
@ -166,7 +147,7 @@ export function cssModulesWebpackRule(
|
|||||||
{
|
{
|
||||||
loader: "css-loader",
|
loader: "css-loader",
|
||||||
options: {
|
options: {
|
||||||
sourceMap: isDevelopment,
|
// sourceMap: isDevelopment,
|
||||||
modules: {
|
modules: {
|
||||||
auto: /\.module\./i, // https://github.com/webpack-contrib/css-loader#auto
|
auto: /\.module\./i, // https://github.com/webpack-contrib/css-loader#auto
|
||||||
mode: "local", // :local(.selector) by default
|
mode: "local", // :local(.selector) by default
|
||||||
@ -177,7 +158,7 @@ export function cssModulesWebpackRule(
|
|||||||
{
|
{
|
||||||
loader: "postcss-loader",
|
loader: "postcss-loader",
|
||||||
options: {
|
options: {
|
||||||
sourceMap: isDevelopment,
|
// sourceMap: isDevelopment,
|
||||||
postcssOptions: {
|
postcssOptions: {
|
||||||
plugins: [
|
plugins: [
|
||||||
"tailwindcss",
|
"tailwindcss",
|
||||||
@ -188,7 +169,7 @@ export function cssModulesWebpackRule(
|
|||||||
{
|
{
|
||||||
loader: "sass-loader",
|
loader: "sass-loader",
|
||||||
options: {
|
options: {
|
||||||
sourceMap: isDevelopment,
|
// sourceMap: isDevelopment,
|
||||||
additionalData: `@import "${path.basename(sassCommonVars)}";`,
|
additionalData: `@import "${path.basename(sassCommonVars)}";`,
|
||||||
sassOptions: {
|
sassOptions: {
|
||||||
includePaths: [
|
includePaths: [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user