mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
extensions-api -- separated webpack config
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
b6f6094e3e
commit
4ab44bda3f
@ -1,5 +1,19 @@
|
||||
// Lens-extensions api developer's kit
|
||||
|
||||
export type { LensRendererRuntimeEnv } from "./extension-api.runtime";
|
||||
|
||||
// APIs
|
||||
export * from "./extension"
|
||||
|
||||
// Common UI components
|
||||
export * from "../renderer/components/icon"
|
||||
export * from "../renderer/components/badge"
|
||||
export * from "../renderer/components/tooltip"
|
||||
export * from "../renderer/components/button"
|
||||
export * from "../renderer/components/input"
|
||||
export * from "../renderer/components/select"
|
||||
export * from "../renderer/components/checkbox"
|
||||
export * from "../renderer/components/radio"
|
||||
export * from "../renderer/components/slider"
|
||||
export * from "../renderer/components/spinner"
|
||||
export * from "../renderer/components/tabs"
|
||||
export * from "../renderer/components/line-progress"
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"outDir": "./out",
|
||||
"jsx": "react",
|
||||
"target": "ES2017",
|
||||
"module": "ESNext",
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
import path from "path";
|
||||
import webpack, { LibraryTarget } from "webpack";
|
||||
import { isDevelopment, buildDir } from "./src/common/vars";
|
||||
|
||||
export const library = "dll"
|
||||
export const libraryTarget: LibraryTarget = "commonjs2"
|
||||
export const manifestPath = path.resolve(buildDir, `${library}.manifest.json`);
|
||||
|
||||
export const packages = [
|
||||
"react", "react-dom",
|
||||
"ace-builds", "xterm",
|
||||
"moment",
|
||||
];
|
||||
|
||||
export default function (): webpack.Configuration {
|
||||
return {
|
||||
context: path.dirname(manifestPath),
|
||||
mode: isDevelopment ? "development" : "production",
|
||||
cache: isDevelopment,
|
||||
entry: {
|
||||
[library]: packages,
|
||||
},
|
||||
output: {
|
||||
library,
|
||||
libraryTarget,
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DllPlugin({
|
||||
name: library,
|
||||
path: manifestPath,
|
||||
})
|
||||
],
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import { appName, buildDir, extensionsLibName, extensionsDir, htmlTemplate, isDevelopment, isProduction, publicPath, rendererDir, sassCommonVars } from "./src/common/vars";
|
||||
import { appName, buildDir, extensionsDir, extensionsLibName, htmlTemplate, isDevelopment, isProduction, publicPath, rendererDir, sassCommonVars } from "./src/common/vars";
|
||||
import path from "path";
|
||||
import webpack from "webpack";
|
||||
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||
@ -6,24 +6,43 @@ import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
||||
import TerserPlugin from "terser-webpack-plugin";
|
||||
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
|
||||
|
||||
export default function (): webpack.Configuration {
|
||||
console.info('WEBPACK:renderer', require("./src/common/vars"))
|
||||
export default [
|
||||
webpackLensRenderer,
|
||||
webpackExtensionsApi,
|
||||
]
|
||||
|
||||
// todo: use common chunks/externals for "react", "react-dom", etc.
|
||||
export function webpackExtensionsApi(): webpack.Configuration {
|
||||
const config = webpackLensRenderer({ showVars: false });
|
||||
config.name = "extensions-api"
|
||||
config.entry = {
|
||||
[extensionsLibName]: path.resolve(extensionsDir, "extension-api.ts")
|
||||
};
|
||||
config.output.libraryTarget = "commonjs2"
|
||||
delete config.devtool;
|
||||
delete config.plugins;
|
||||
return config;
|
||||
}
|
||||
|
||||
export function webpackLensRenderer({ showVars = true } = {}): webpack.Configuration {
|
||||
if (showVars) {
|
||||
console.info('WEBPACK:renderer', require("./src/common/vars"));
|
||||
}
|
||||
return {
|
||||
context: __dirname,
|
||||
target: "electron-renderer",
|
||||
devtool: "source-map", // todo: optimize in dev-mode with webpack.SourceMapDevToolPlugin
|
||||
name: "lens-app",
|
||||
mode: isProduction ? "production" : "development",
|
||||
cache: isDevelopment,
|
||||
entry: {
|
||||
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
||||
[extensionsLibName]: path.resolve(extensionsDir, "extension-api.ts"),
|
||||
},
|
||||
output: {
|
||||
publicPath: publicPath,
|
||||
path: buildDir,
|
||||
filename: '[name].js',
|
||||
chunkFilename: 'chunks/[name].js',
|
||||
libraryTarget: "commonjs2",
|
||||
},
|
||||
resolve: {
|
||||
extensions: [
|
||||
@ -152,7 +171,6 @@ export default function (): webpack.Configuration {
|
||||
filename: `${appName}.html`,
|
||||
template: htmlTemplate,
|
||||
inject: true,
|
||||
excludeChunks: [extensionsLibName],
|
||||
}),
|
||||
|
||||
new MiniCssExtractPlugin({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user