mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
feat: copy public assets from plugins to final build
This commit is contained in:
@@ -9,10 +9,25 @@ const path = require('path');
|
||||
|
||||
const currentDir = process.cwd();
|
||||
|
||||
const webpackArgv = {
|
||||
mode: 'production',
|
||||
pluginsList: '',
|
||||
currentDir: currentDir,
|
||||
|
||||
function createWebpackArgv(argv) {
|
||||
|
||||
const fullPath = path.resolve(currentDir, argv.pluginsList || './plugins-list')
|
||||
let pluginsList = [];
|
||||
try {
|
||||
pluginsList = require(fullPath);
|
||||
} catch (e) {
|
||||
console.log('Plugins list is not found: ', fullPath);
|
||||
}
|
||||
|
||||
const webpackArgv = {
|
||||
mode: 'production',
|
||||
pluginsList: pluginsList,
|
||||
|
||||
currentDir: currentDir,
|
||||
}
|
||||
return webpackArgv;
|
||||
|
||||
}
|
||||
|
||||
const packageJson = require(path.join(currentDir, 'package.json'));
|
||||
@@ -35,10 +50,8 @@ function createRollupConfig() {
|
||||
moduleDir = module ? `/${module}` : ''; // don't add slash for root module
|
||||
const moduleConfig = {...baseRollupConfig};
|
||||
moduleConfig.input = `src${moduleDir}/index.ts`;
|
||||
moduleConfig.output = {
|
||||
dir: `dist${moduleDir}`,
|
||||
format: 'esm',
|
||||
};
|
||||
moduleConfig.output = {...baseRollupConfig.output};
|
||||
moduleConfig.output.dir = `dist${moduleDir}`;
|
||||
|
||||
moduleConfig.external = [
|
||||
...baseRollupConfig.external,
|
||||
@@ -55,6 +68,15 @@ function createRollupConfig() {
|
||||
}
|
||||
|
||||
require('yargs')
|
||||
.options({
|
||||
'l': {
|
||||
alias: 'pluginsList',
|
||||
demandOption: false,
|
||||
default: '',
|
||||
describe: 'path to plugins list relative to product location',
|
||||
type: 'string'
|
||||
}
|
||||
})
|
||||
// build-plugin and serve-plugin use rollup
|
||||
.command(
|
||||
'build-plugin',
|
||||
@@ -105,6 +127,8 @@ require('yargs')
|
||||
'Build application',
|
||||
{},
|
||||
function (argv) {
|
||||
const webpackArgv = createWebpackArgv(argv);
|
||||
// console.log(webpackArgv)
|
||||
const configObject = buildConfig({}, webpackArgv)
|
||||
const compiler = webpack(configObject);
|
||||
|
||||
@@ -113,6 +137,36 @@ require('yargs')
|
||||
});
|
||||
}
|
||||
)
|
||||
.command(
|
||||
'serve-app',
|
||||
'Start webpack dev server for serving application',
|
||||
{
|
||||
server: {
|
||||
alias: 's',
|
||||
default: 'localhost:3100'
|
||||
},
|
||||
port: {
|
||||
alias: 'p',
|
||||
default: 3100
|
||||
}
|
||||
},
|
||||
function (argv) {
|
||||
const webpackArgv = createWebpackArgv(argv);
|
||||
webpackArgv.mode = 'development'
|
||||
webpackArgv.server = argv.server
|
||||
const configObject = devConfig({}, webpackArgv)
|
||||
const WebpackDevServer = require('webpack-dev-server');
|
||||
const server = new WebpackDevServer(webpack(configObject), configObject.devServer);
|
||||
const port = argv.port
|
||||
|
||||
server.listen(port, 'localhost', function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log('WebpackDevServer listening at localhost:', port);
|
||||
});
|
||||
}
|
||||
)
|
||||
// todo deprecated, just for test purposes
|
||||
.command(
|
||||
'serve-app-old',
|
||||
@@ -130,6 +184,7 @@ require('yargs')
|
||||
function (argv) {
|
||||
console.log('Serve app old way')
|
||||
console.log(argv)
|
||||
const webpackArgv = createWebpackArgv(argv);
|
||||
webpackArgv.mode = 'development'
|
||||
webpackArgv.server = argv.server
|
||||
const devConfigOld = require('../configs/webpack/dev')
|
||||
@@ -147,34 +202,4 @@ require('yargs')
|
||||
});
|
||||
}
|
||||
)
|
||||
.command(
|
||||
'serve-app',
|
||||
'Start webpack dev server for serving application',
|
||||
{
|
||||
server: {
|
||||
alias: 's',
|
||||
default: 'localhost:3100'
|
||||
},
|
||||
port: {
|
||||
alias: 'p',
|
||||
default: 3100
|
||||
}
|
||||
},
|
||||
function (argv) {
|
||||
webpackArgv.mode = 'development'
|
||||
webpackArgv.server = argv.server
|
||||
const configObject = devConfig({}, webpackArgv)
|
||||
const WebpackDevServer = require('webpack-dev-server');
|
||||
const server = new WebpackDevServer(webpack(configObject), configObject.devServer);
|
||||
const port = argv.port
|
||||
|
||||
server.listen(port, 'localhost', function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log('WebpackDevServer listening at localhost:', port);
|
||||
});
|
||||
}
|
||||
)
|
||||
.help()
|
||||
.argv
|
||||
.help().argv;
|
||||
|
||||
@@ -28,6 +28,7 @@ function configBuilder(options = defaultBuilderOptions) {
|
||||
output: {
|
||||
dir: 'dist',
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
},
|
||||
external: [
|
||||
// externals beyond peer dependencies
|
||||
|
||||
@@ -5,10 +5,10 @@ const webpack = require('webpack');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
const resolve = require('resolve');
|
||||
const fs = require('fs');
|
||||
|
||||
function replacementWithPluginImportCode(pathToList, currentDir) {
|
||||
const fullPath = path.resolve(currentDir, pathToList || './plugins-list')
|
||||
const pluginsList = require(fullPath);
|
||||
function replacementWithPluginImportCode(pluginsList, currentDir) {
|
||||
|
||||
let code = '';
|
||||
const names = [];
|
||||
@@ -28,6 +28,28 @@ ${names.map(n => ` ${n},\n`).join('')}]`;
|
||||
return code;
|
||||
}
|
||||
|
||||
function copyPublic(currentDir, pluginsList) {
|
||||
const pathsToCopy = [];
|
||||
|
||||
pluginsList.forEach(plugin => {
|
||||
try {
|
||||
const pathToPlugin = resolve.sync(plugin, {basedir: currentDir});
|
||||
const dir = path.parse(pathToPlugin).dir;
|
||||
const pathToPublic = path.resolve(dir, '../public');
|
||||
const stats = fs.statSync(pathToPublic);
|
||||
if (stats && stats.isDirectory()) {
|
||||
pathsToCopy.push({
|
||||
from: pathToPublic,
|
||||
to: '',
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
});
|
||||
pathsToCopy.push({from: path.resolve(currentDir, './public'), to: ''});
|
||||
console.log(pathsToCopy);
|
||||
return pathsToCopy;
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
resolve: {
|
||||
@@ -60,14 +82,15 @@ module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
return replacementWithPluginImportCode(argv.pluginsList, argv.currentDir);
|
||||
}
|
||||
}
|
||||
]})
|
||||
]
|
||||
})
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([ { from: path.resolve(argv.currentDir, './public'), to: '' } ]),
|
||||
new CopyWebpackPlugin(copyPublic(argv.currentDir, argv.pluginsList)),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(argv.currentDir, './index.html.ejs'),
|
||||
}),
|
||||
|
||||
@@ -11,24 +11,83 @@
|
||||
"@dbeaver/core": "^0.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"go-split": "^1.3.2",
|
||||
"@babel/cli": "^7.7.4",
|
||||
"@babel/core": "^7.7.4",
|
||||
"@babel/plugin-proposal-decorators": "^7.7.4",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||
"@babel/plugin-transform-runtime": "^7.8.3",
|
||||
"@babel/preset-env": "^7.7.4",
|
||||
"@babel/preset-react": "^7.7.4",
|
||||
"@babel/preset-typescript": "^7.7.4",
|
||||
"@csstools/postcss-sass": "^4.0.0",
|
||||
"@material/button": "^4.0.0",
|
||||
"@material/elevation": "^4.0.0",
|
||||
"@material/ripple": "^4.0.0",
|
||||
"@material/theme": "^4.0.0",
|
||||
"@material/typography": "^4.0.0",
|
||||
"@types/graphql": "^14.5.0",
|
||||
"@types/jest": "^24.0.23",
|
||||
"@types/node": "^12.7.8",
|
||||
"@types/react": "^16.9.34",
|
||||
"@types/react-dom": "^16.9.6",
|
||||
"@typescript-eslint/eslint-plugin": "^2.5.0",
|
||||
"@typescript-eslint/parser": "^2.8.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-react-require": "^3.1.1",
|
||||
"babel-plugin-transform-typescript-metadata": "^0.2.2",
|
||||
"circular-dependency-plugin": "^5.2.0",
|
||||
"copy-webpack-plugin": "^5.1.0",
|
||||
"css-loader": "^3.2.1",
|
||||
"extract-css-chunks-webpack-plugin": "^4.7.1",
|
||||
"file-loader": "^5.0.2",
|
||||
"fork-ts-checker-webpack-plugin": "^4.0.5",
|
||||
"go-split": "^1.3.2",
|
||||
"graphql": "^14.5.8",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"mobx": "^5.15.4",
|
||||
"mobx-react": "^6.2.2",
|
||||
"node-sass": "^4.13.0",
|
||||
"postcss-discard-comments": "^4.0.2",
|
||||
"postcss-extend-rule": "^3.0.0",
|
||||
"postcss-import": "^12.0.1",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"postcss-scss": "^2.0.0",
|
||||
"preact": "^10.4.1",
|
||||
"preact-render-to-string": "^5.1.6",
|
||||
"preact-ssr-prepass": "^1.0.1",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier-eslint": "^9.0.0",
|
||||
"raw-loader": "^3.1.0",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-hot-loader": "^4.12.18",
|
||||
"reakit": "1.0.0-beta.11",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"reshadow": "0.0.1-alpha.75",
|
||||
"resolve": "^1.17.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"rollup": "^2.0.6",
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-includepaths": "^0.2.3",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-peer-deps-external": "^2.2.2",
|
||||
"rollup-plugin-postcss": "dkrupenya/rollup-plugin-postcss#develop",
|
||||
"rollup-plugin-typescript2": "^0.26.0",
|
||||
"rxjs": "^6.5.5",
|
||||
"sass-loader": "^8.0.0",
|
||||
"source-map-loader": "^0.2.4",
|
||||
"string-replace-webpack-plugin": "^0.1.3",
|
||||
"style-loader": "^1.0.1",
|
||||
"typescript": "^3.8.3",
|
||||
"url-loader": "^3.0.0",
|
||||
"webpack": "^4.41.2",
|
||||
"webpack-cli": "^3.3.10",
|
||||
"webpack-dev-middleware": "^3.7.2",
|
||||
"webpack-dev-server": "^3.9.0",
|
||||
"webpack-merge": "^4.2.2",
|
||||
"yargs": "^15.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"jsx": "preserve",
|
||||
"isolatedModules": true,
|
||||
|
||||
+25
-18
@@ -2197,7 +2197,7 @@
|
||||
dependencies:
|
||||
"@types/node" ">= 8"
|
||||
|
||||
"@reshadow/babel@^0.0.1-alpha.76":
|
||||
"@reshadow/babel@^0.0.1-alpha.75", "@reshadow/babel@^0.0.1-alpha.76":
|
||||
version "0.0.1-alpha.76"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/babel/-/babel-0.0.1-alpha.76.tgz#de1e103f015743cc6afa7786b0f255a1fa45677e"
|
||||
integrity sha512-+BNbDkV6sQJQWEpWVNFEA0B6kiwIZgXf9t7WcvCEEVp7ckb57gapNV18MRxZX7ADVKchlXatyo8V015oqpHbDw==
|
||||
@@ -2233,7 +2233,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/core/-/core-0.0.1-alpha.74.tgz#57ea3249ad8162306d0d83e5446a5e7774b81f3e"
|
||||
integrity sha512-oYATyZXe0gLbOnqDa01T5HeivUiEY7LxyfbTYVX6Q8pIWvfBJE0ftrrJkeKA2PW5HilE7qWxn7tmlX2YQFowSg==
|
||||
|
||||
"@reshadow/eslint@^0.0.1-alpha.76":
|
||||
"@reshadow/eslint@^0.0.1-alpha.75":
|
||||
version "0.0.1-alpha.76"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/eslint/-/eslint-0.0.1-alpha.76.tgz#9146e67aedf9f8d37543fbac23429395bbb6da01"
|
||||
integrity sha512-fdAWBBRzR1xiBxiyMzF3sX5E+KgwUYHOSj/00ue/iVJ0xNhdd/C42FcnFZ/galqNumBcHfVxauVrjWJ0oV5Y1Q==
|
||||
@@ -2241,7 +2241,7 @@
|
||||
"@babel/types" "^7.5.5"
|
||||
"@reshadow/utils" "^0.0.1-alpha.75"
|
||||
|
||||
"@reshadow/macro@^0.0.1-alpha.76":
|
||||
"@reshadow/macro@^0.0.1-alpha.75":
|
||||
version "0.0.1-alpha.76"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/macro/-/macro-0.0.1-alpha.76.tgz#f11d75015639b69440bc15fc1947c0b8141b4975"
|
||||
integrity sha512-g6Qt2mBWijMSxwWhX9gixE6RdNKs80FnmIy3zfndeEE0SqUv27FK4t8Q3Yp0oolIyPqPJkvNANVZ3RxRTbLUIw==
|
||||
@@ -2250,7 +2250,7 @@
|
||||
"@reshadow/core" "^0.0.1-alpha.74"
|
||||
babel-plugin-macros "2.5.1"
|
||||
|
||||
"@reshadow/postcss@^0.0.1-alpha.76":
|
||||
"@reshadow/postcss@^0.0.1-alpha.72", "@reshadow/postcss@^0.0.1-alpha.76":
|
||||
version "0.0.1-alpha.76"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/postcss/-/postcss-0.0.1-alpha.76.tgz#0957b1f87134dd0f8dea6660b8359eb96fef97c4"
|
||||
integrity sha512-VYqh1z6fytNpu1ENA/KfO18IqBSkOeyDLckuWpVPo3fvIXIc+6AQWgRGYv+3P5UQ0eDwcNVzmgZUZZ+/tX7Tag==
|
||||
@@ -2265,7 +2265,7 @@
|
||||
dependencies:
|
||||
prettier "1.18.2"
|
||||
|
||||
"@reshadow/react@^0.0.1-alpha.77":
|
||||
"@reshadow/react@^0.0.1-alpha.75":
|
||||
version "0.0.1-alpha.77"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/react/-/react-0.0.1-alpha.77.tgz#b520b74d801b933d254b7e1233ab711e3b996118"
|
||||
integrity sha512-jOYsBIRNBnE9kkyil/H10y3frDyaSIGKRtbCHbHJJ5v7Vtog0p1J4W+yw7lroc34v/i333XJuyc7YIAHQuIgow==
|
||||
@@ -2286,7 +2286,7 @@
|
||||
"@reshadow/core" "^0.0.1-alpha.74"
|
||||
string-hash "^1.1.3"
|
||||
|
||||
"@reshadow/svelte@^0.0.1-alpha.76":
|
||||
"@reshadow/svelte@^0.0.1-alpha.75":
|
||||
version "0.0.1-alpha.76"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/svelte/-/svelte-0.0.1-alpha.76.tgz#3a4c1b524aa9bd3d06a84f5e01df8a94a823964e"
|
||||
integrity sha512-I32evIUABRy+g5S34VLHg8tnHpR4SVD4l8mzkZNCngOEh0rWY8Nf8cm8uVERa54nu5+hZRYdgsVQ0WUxsvfwzw==
|
||||
@@ -2317,7 +2317,7 @@
|
||||
dependencies:
|
||||
"@reshadow/core" "^0.0.1-alpha.74"
|
||||
|
||||
"@reshadow/webpack@^0.0.1-alpha.77":
|
||||
"@reshadow/webpack@^0.0.1-alpha.75":
|
||||
version "0.0.1-alpha.77"
|
||||
resolved "https://registry.yarnpkg.com/@reshadow/webpack/-/webpack-0.0.1-alpha.77.tgz#725a39e79c39c519cf31e650f7fb7d5c62badec7"
|
||||
integrity sha512-8Y05FyO/iRmJ32isvR5C5jsno/Wkiq9gmCPlzUDKQNAYA92ZAeqhHvx1byS8G8v6Vh1iHbyAKFrqySK8TgoOVw==
|
||||
@@ -11437,21 +11437,21 @@ requires-port@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
|
||||
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
|
||||
|
||||
reshadow@0.0.1-alpha.77:
|
||||
version "0.0.1-alpha.77"
|
||||
resolved "https://registry.yarnpkg.com/reshadow/-/reshadow-0.0.1-alpha.77.tgz#7958e5f17a9595f7517de95c540d6428707fe645"
|
||||
integrity sha512-tsJjExIvn/DCT/lv+Bm35e+7MWuPV/HcsB70+xz1oCLCKmFUDlDp/43pTMfF070OLzB5fwWHV8caNyPPUxMOjg==
|
||||
reshadow@0.0.1-alpha.75:
|
||||
version "0.0.1-alpha.75"
|
||||
resolved "https://registry.yarnpkg.com/reshadow/-/reshadow-0.0.1-alpha.75.tgz#f8ba5345b8f5856c71fa04fabc2e9161cb374cad"
|
||||
integrity sha512-KqhA1Xr8KcC/PxJdI2fFXv1g59P6Ki7peLXtnlP2mPQ0ZxLjt96LnQmMQp55NZvZOB3rCqYcDhGizMRHSNK+Qg==
|
||||
dependencies:
|
||||
"@reshadow/babel" "^0.0.1-alpha.76"
|
||||
"@reshadow/babel" "^0.0.1-alpha.75"
|
||||
"@reshadow/core" "^0.0.1-alpha.74"
|
||||
"@reshadow/eslint" "^0.0.1-alpha.76"
|
||||
"@reshadow/macro" "^0.0.1-alpha.76"
|
||||
"@reshadow/postcss" "^0.0.1-alpha.76"
|
||||
"@reshadow/eslint" "^0.0.1-alpha.75"
|
||||
"@reshadow/macro" "^0.0.1-alpha.75"
|
||||
"@reshadow/postcss" "^0.0.1-alpha.72"
|
||||
"@reshadow/prettier" "0.0.1-alpha.70"
|
||||
"@reshadow/react" "^0.0.1-alpha.77"
|
||||
"@reshadow/svelte" "^0.0.1-alpha.76"
|
||||
"@reshadow/react" "^0.0.1-alpha.75"
|
||||
"@reshadow/svelte" "^0.0.1-alpha.75"
|
||||
"@reshadow/vue" "^0.0.1-alpha.74"
|
||||
"@reshadow/webpack" "^0.0.1-alpha.77"
|
||||
"@reshadow/webpack" "^0.0.1-alpha.75"
|
||||
|
||||
resolve-cwd@^2.0.0:
|
||||
version "2.0.0"
|
||||
@@ -11502,6 +11502,13 @@ resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.13
|
||||
dependencies:
|
||||
path-parse "^1.0.6"
|
||||
|
||||
resolve@^1.17.0:
|
||||
version "1.17.0"
|
||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444"
|
||||
integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
|
||||
dependencies:
|
||||
path-parse "^1.0.6"
|
||||
|
||||
restore-cursor@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
|
||||
|
||||
Reference in New Issue
Block a user