mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
chore: cleanup webpack config
This commit is contained in:
+4
-6
@@ -14,12 +14,10 @@
|
||||
"scripts": {
|
||||
"bootstrap": "lerna bootstrap",
|
||||
"build": "lerna run build --stream",
|
||||
"build-plugin": "lerna run build-plugin --stream",
|
||||
"clean-dist": "lerna run clean-dist",
|
||||
"start": "lerna run start --stream",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"tsc": "lerna run tsc --stream",
|
||||
"watch": "lerna run watch --stream"
|
||||
"serve": "lerna run serve --stream",
|
||||
"serve-plugin": "lerna run serve-plugin --stream --parallel",
|
||||
"clean-dist": "lerna run clean-dist --stream",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "7.8.4"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
const webpack = require('webpack');
|
||||
const buildConfig = require('../configs/webpack/exp')
|
||||
const devConfig = require('../configs/webpack/dev-exp')
|
||||
const buildConfig = require('../configs/webpack-build-config');
|
||||
const devConfig = require('../configs/webpack-serve-config');
|
||||
const baseRollupConfig = require('../configs/rollup.config.js');
|
||||
const rollup = require('rollup');
|
||||
const path = require('path');
|
||||
@@ -32,7 +32,7 @@ function createWebpackArgv(argv) {
|
||||
pluginsList.unshift('@dbeaver/core')
|
||||
|
||||
const webpackArgv = {
|
||||
mode: 'production',
|
||||
mode: argv.mode,
|
||||
pluginsList: pluginsList,
|
||||
|
||||
currentDir: currentDir,
|
||||
@@ -48,6 +48,7 @@ const packageName = packageJson.name;
|
||||
function createRollupConfig() {
|
||||
let modules = []
|
||||
try {
|
||||
// required if you build plugin with several modules, for example, see @dbeaver/core
|
||||
modules = require(path.join(currentDir, 'modules.js'));
|
||||
} catch {
|
||||
}
|
||||
@@ -116,7 +117,6 @@ require('yargs')
|
||||
.command(
|
||||
'serve-plugin',
|
||||
'Build and watch plugin',
|
||||
{},
|
||||
function (argv) {
|
||||
const rollup = require('rollup');
|
||||
|
||||
@@ -136,7 +136,12 @@ require('yargs')
|
||||
.command(
|
||||
'build-app',
|
||||
'Build application',
|
||||
{},
|
||||
{
|
||||
mode: {
|
||||
alias: 'm',
|
||||
default: 'production',
|
||||
},
|
||||
},
|
||||
function (argv) {
|
||||
const webpackArgv = createWebpackArgv(argv);
|
||||
// console.log(webpackArgv)
|
||||
@@ -159,7 +164,11 @@ require('yargs')
|
||||
port: {
|
||||
alias: 'p',
|
||||
default: 3100
|
||||
}
|
||||
},
|
||||
mode: {
|
||||
alias: 'm',
|
||||
default: 'development',
|
||||
},
|
||||
},
|
||||
function (argv) {
|
||||
const webpackArgv = createWebpackArgv(argv);
|
||||
@@ -178,39 +187,4 @@ require('yargs')
|
||||
});
|
||||
}
|
||||
)
|
||||
// todo deprecated, just for test purposes
|
||||
.command(
|
||||
'serve-app-old',
|
||||
'Start webpack dev server for serving application',
|
||||
{
|
||||
server: {
|
||||
alias: 's',
|
||||
default: 'localhost:3100'
|
||||
},
|
||||
port: {
|
||||
alias: 'p',
|
||||
default: 3100
|
||||
}
|
||||
},
|
||||
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')
|
||||
const configObject = devConfigOld({}, webpackArgv)
|
||||
console.log(configObject.devServer)
|
||||
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;
|
||||
|
||||
@@ -18,7 +18,7 @@ const includePathOptions = {
|
||||
};
|
||||
|
||||
const defaultBuilderOptions = {
|
||||
babelConfig: path.join(__dirname, './babel-rollup.config.js'),
|
||||
babelConfig: path.join(__dirname, './babel-plugin.config.js'),
|
||||
typescriptConfig: '', // tbd
|
||||
}
|
||||
|
||||
@@ -34,9 +34,16 @@ function configBuilder(options = defaultBuilderOptions) {
|
||||
external: [
|
||||
// externals beyond peer dependencies
|
||||
],
|
||||
onwarn(warning, warn) {
|
||||
// hides some warning drom ag-grid-plugin todo to investigate later
|
||||
if (warning.code === 'THIS_IS_UNDEFINED') return;
|
||||
warn(warning); // this requires Rollup 0.46
|
||||
},
|
||||
plugins: [
|
||||
includePaths(includePathOptions),
|
||||
nodeResolve(),
|
||||
nodeResolve({
|
||||
preferBuiltins: true, // fix crypto import in core/utils/uuid library. todo replace uuid library with simple uuid generation
|
||||
}),
|
||||
commonjs({
|
||||
sourceMap: false,
|
||||
}),
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// production config
|
||||
const merge = require('webpack-merge');
|
||||
const path = require('path');
|
||||
|
||||
const commonConfig = require('./webpack-common-config');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode,
|
||||
entry: './index.js',
|
||||
output: {
|
||||
filename: 'js/bundle.[hash].js',
|
||||
path: path.resolve(argv.currentDir, './dist'),
|
||||
publicPath: '',
|
||||
},
|
||||
devtool: 'source-map',
|
||||
plugins: [],
|
||||
optimization: {
|
||||
minimize: false,
|
||||
namedModules: true,
|
||||
concatenateModules: false,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* cloudbeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
const webpack = require('webpack');
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
const resolve = require('resolve');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
function replacementWithPluginImportCode(pluginsList) {
|
||||
|
||||
let code = '';
|
||||
const names = [];
|
||||
|
||||
pluginsList.forEach(plugin => {
|
||||
const name = plugin
|
||||
.split('')
|
||||
.filter(char => /[a-zA-Z]/.test(char))
|
||||
.join('');
|
||||
names.push(name);
|
||||
|
||||
code += `import ${name} from '${plugin}';\n`;
|
||||
})
|
||||
code += `
|
||||
const PLUGINS = [
|
||||
${names.map(n => ` ${n},\n`).join('')}]`;
|
||||
return code;
|
||||
}
|
||||
|
||||
function dirExists(path) {
|
||||
try {
|
||||
const stats = fs.statSync(path)
|
||||
return stats && stats.isDirectory()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function copyPublic(currentDir, pluginsList) {
|
||||
const pathsToCopy = [];
|
||||
pluginsList.forEach(plugin => {
|
||||
try {
|
||||
const pathToPlugin = resolve.sync(plugin);
|
||||
const dir = path.parse(pathToPlugin).dir;
|
||||
const pathToPublic = path.resolve(dir, '../public');
|
||||
if (dirExists(pathToPublic)) {
|
||||
pathsToCopy.push({
|
||||
from: pathToPublic,
|
||||
to: '',
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
const pathToAppPublic = path.resolve(currentDir, './public')
|
||||
if (dirExists(pathToAppPublic)) {
|
||||
pathsToCopy.push({from: path.resolve(currentDir, './public'), to: ''});
|
||||
}
|
||||
return pathsToCopy;
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
return {
|
||||
context: path.resolve(__dirname, '../src'),
|
||||
resolve: {
|
||||
extensions: ['.js'],
|
||||
alias: {
|
||||
react: 'preact/compat',
|
||||
react$: 'preact/compat',
|
||||
'react-dom': 'preact/compat',
|
||||
'react-dom$': 'preact/compat',
|
||||
},
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
configFile: path.join(__dirname, './babel-app.config.js')
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: StringReplacePlugin.replace({
|
||||
/**
|
||||
* This replacement allows to put into the build the plugins that were mentioned in package.json
|
||||
*/
|
||||
replacements: [
|
||||
{
|
||||
pattern: /const PLUGINS = \[]/ig,
|
||||
replacement: function (match, p1, offset, string) {
|
||||
return replacementWithPluginImportCode(argv.pluginsList);
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
},
|
||||
'source-map-loader'
|
||||
],
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin(copyPublic(argv.currentDir, argv.pluginsList)),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(argv.currentDir, './index.html.ejs'),
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
version: JSON.stringify(require(path.resolve(argv.currentDir, './package.json')).buildVersion),
|
||||
}),
|
||||
new webpack.ProgressPlugin({
|
||||
entries: true,
|
||||
modules: true,
|
||||
modulesCount: 100,
|
||||
profile: true,
|
||||
// handler: (percentage, message, ...args) => {
|
||||
// // custom logic
|
||||
// }
|
||||
}),
|
||||
new CircularDependencyPlugin({
|
||||
// exclude detection of files based on a RegExp
|
||||
// exclude: /\.js|node_modules/,
|
||||
// include specific files based on a RegExp
|
||||
// include: /dir/,
|
||||
// add errors to webpack instead of warnings
|
||||
failOnError: false,
|
||||
// allow import cycles that include an asyncronous import,
|
||||
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
||||
allowAsyncCycles: false,
|
||||
// set the current working directory for displaying module paths
|
||||
cwd: process.cwd(),
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
// Options similar to the same options in webpackOptions.output
|
||||
// all options are optional
|
||||
filename: argv.mode !== 'production' ? '[name].css' : '[name].[hash].css',
|
||||
chunkFilename: argv.mode !== 'production' ? '[name].css' : '[name].[hash].css',
|
||||
ignoreOrder: false, // Enable to remove warnings about conflicting order
|
||||
}),
|
||||
// new webpack.optimize.LimitChunkCountPlugin({
|
||||
// maxChunks: 1,
|
||||
// }),
|
||||
],
|
||||
performance: {
|
||||
hints: false,
|
||||
},
|
||||
optimization: {
|
||||
minimize: false,
|
||||
namedModules: true,
|
||||
concatenateModules: false,
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
// development config
|
||||
const merge = require('webpack-merge');
|
||||
const webpack = require('webpack');
|
||||
const commonConfig = require('./webpack-common-config');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode,
|
||||
entry: [
|
||||
// 'react-hot-loader/patch', // activate HMR for React
|
||||
'webpack-dev-server/client?http://localhost:3100',// bundle the client for webpack-dev-server and connect to the provided endpoint
|
||||
// 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates
|
||||
'./index.js' // the entry point of our app
|
||||
],
|
||||
devServer: {
|
||||
hot: false, // enable HMR on the server
|
||||
proxy: {
|
||||
'/dbeaver': {
|
||||
target: argv.server || 'localhost:3100'
|
||||
}
|
||||
}
|
||||
},
|
||||
devtool: 'cheap-module-eval-source-map',
|
||||
plugins: [
|
||||
// new webpack.HotModuleReplacementPlugin(), // enable HMR globally
|
||||
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
|
||||
],
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
const merge = require('webpack-merge');
|
||||
const {resolve} = require('path');
|
||||
var PeerDepsExternalsPlugin = require('peer-deps-externals-webpack-plugin');
|
||||
|
||||
const commonConfig = require('./common');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode || 'development',
|
||||
entry: resolve(__dirname, '../../src/index.ts'), // todo
|
||||
output: {
|
||||
filename: 'index.js',
|
||||
path: resolve(__dirname, '../../dist'),
|
||||
library: 'basicConnectionPlugin', // todo pass from package.js
|
||||
libraryTarget: 'umd',
|
||||
},
|
||||
externals: [
|
||||
/^@dbeaver\/.+$/
|
||||
],
|
||||
devtool: 'source-map',
|
||||
plugins: [
|
||||
new PeerDepsExternalsPlugin(), // allow to treat all peerDependencies as externals
|
||||
],
|
||||
});
|
||||
@@ -1,108 +0,0 @@
|
||||
const merge = require('webpack-merge');
|
||||
const commonConfig = require('./common-root');
|
||||
const path = require('path');
|
||||
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(pluginsList, currentDir) {
|
||||
|
||||
let code = '';
|
||||
const names = [];
|
||||
|
||||
pluginsList.forEach(plugin => {
|
||||
const name = plugin
|
||||
.split('')
|
||||
.filter(char => /[a-zA-Z]/.test(char))
|
||||
.join('');
|
||||
names.push(name);
|
||||
|
||||
code += `import ${name} from '${plugin}';\n`;
|
||||
})
|
||||
code += `
|
||||
const PLUGINS = [
|
||||
${names.map(n => ` ${n},\n`).join('')}]`;
|
||||
return code;
|
||||
}
|
||||
|
||||
function dirExists(path) {
|
||||
try {
|
||||
const stats = fs.statSync(path)
|
||||
return stats && stats.isDirectory()
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function copyPublic(currentDir, pluginsList) {
|
||||
const pathsToCopy = [];
|
||||
pluginsList.forEach(plugin => {
|
||||
try {
|
||||
const pathToPlugin = resolve.sync(plugin);
|
||||
const dir = path.parse(pathToPlugin).dir;
|
||||
const pathToPublic = path.resolve(dir, '../public');
|
||||
if (dirExists(pathToPublic)) {
|
||||
pathsToCopy.push({
|
||||
from: pathToPublic,
|
||||
to: '',
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
const pathToAppPublic = path.resolve(currentDir, './public')
|
||||
if (dirExists(pathToAppPublic)) {
|
||||
pathsToCopy.push({from: path.resolve(currentDir, './public'), to: ''});
|
||||
}
|
||||
return pathsToCopy;
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
resolve: {
|
||||
alias: {
|
||||
react: 'preact/compat',
|
||||
react$: 'preact/compat',
|
||||
'react-dom': 'preact/compat',
|
||||
'react-dom$': 'preact/compat',
|
||||
},
|
||||
},
|
||||
context: path.resolve(__dirname, '../../src'),
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js?$/,
|
||||
use: [
|
||||
{
|
||||
loader: StringReplacePlugin.replace({
|
||||
/**
|
||||
* This replacement allows to put into the build the plugins that were mentioned in package.json
|
||||
*/
|
||||
replacements: [
|
||||
{
|
||||
pattern: /const PLUGINS = \[]/ig,
|
||||
replacement: function (match, p1, offset, string) {
|
||||
return replacementWithPluginImportCode(argv.pluginsList, argv.currentDir);
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin(copyPublic(argv.currentDir, argv.pluginsList)),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(argv.currentDir, './index.html.ejs'),
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
version: JSON.stringify(require(path.resolve(argv.currentDir, './package.json')).buildVersion),
|
||||
}),
|
||||
],
|
||||
|
||||
});
|
||||
@@ -1,188 +0,0 @@
|
||||
// shared config (dev and prod)
|
||||
const webpack = require('webpack');
|
||||
const ModuleDependencyWarning = require("webpack/lib/ModuleDependencyWarning");
|
||||
const path = require('path');
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
|
||||
|
||||
// Temporary solution to remove wrong warning messages (it's was fixed https://github.com/microsoft/TypeScript/pull/35200 in typescript 3.8)
|
||||
class IgnoreNotFoundExportPlugin {
|
||||
apply(compiler) {
|
||||
const messageRegExp = /export '.*'( \(reexported as '.*'\))? was not found in/
|
||||
function doneHook(stats) {
|
||||
stats.compilation.warnings = stats.compilation.warnings.filter(function (warn) {
|
||||
if (warn instanceof ModuleDependencyWarning && messageRegExp.test(warn.message)) {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
})
|
||||
}
|
||||
if (compiler.hooks) {
|
||||
compiler.hooks.done.tap("IgnoreNotFoundExportPlugin", doneHook)
|
||||
} else {
|
||||
compiler.plugin("done", doneHook)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
|
||||
function generateStyleLoaders(options = { hasModule: false }) {
|
||||
const moduleScope = options.hasModule ? 'local' : 'global';
|
||||
const modules = {
|
||||
mode: moduleScope,
|
||||
localIdentName: '[local]___[hash:base64:5]',
|
||||
};
|
||||
|
||||
const postCssPlugins = [
|
||||
require('postcss-preset-env')({ stage: 0 }),
|
||||
require('@csstools/postcss-sass')({
|
||||
includePaths: ['node_modules', path.resolve('../../node_modules')],
|
||||
}),
|
||||
require('postcss-discard-comments'),
|
||||
require('reshadow/postcss')({ scopeBehaviour: moduleScope })
|
||||
];
|
||||
|
||||
// 'use' clause in webpack rules
|
||||
return [
|
||||
{
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: {
|
||||
hot: argv.mode !== 'production',
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
modules: modules,
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
syntax: 'postcss-scss',
|
||||
plugins: postCssPlugins,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
// extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
||||
extensions: ['.js'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
configFile: path.join(__dirname, '../babel.config.js')
|
||||
},
|
||||
},
|
||||
'source-map-loader'
|
||||
],
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
configFile: path.join(__dirname, '../babel.config.js')
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'eslint-loader',
|
||||
// uncomment to fix after rule changes
|
||||
// options: {
|
||||
// fix: true,
|
||||
// },
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(css|scss|sass)$/,
|
||||
oneOf: [
|
||||
// css-module files ( should have *.module mask )
|
||||
{
|
||||
test: /\.module\.(css|scss|sass)$/,
|
||||
use: generateStyleLoaders({ hasModule: true }),
|
||||
},
|
||||
{
|
||||
include: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: {
|
||||
hot: argv.mode !== 'production',
|
||||
},
|
||||
},
|
||||
'css-loader',
|
||||
]
|
||||
},
|
||||
{
|
||||
use: generateStyleLoaders({ hasModule: false }),
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 8192,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimize: false,
|
||||
namedModules: true,
|
||||
concatenateModules: false,
|
||||
},
|
||||
plugins: [
|
||||
new IgnoreNotFoundExportPlugin(),
|
||||
new webpack.ProgressPlugin({
|
||||
entries: true,
|
||||
modules: true,
|
||||
modulesCount: 100,
|
||||
profile: true,
|
||||
// handler: (percentage, message, ...args) => {
|
||||
// // custom logic
|
||||
// }
|
||||
}),
|
||||
new CircularDependencyPlugin({
|
||||
// exclude detection of files based on a RegExp
|
||||
exclude: /a\.js|node_modules/,
|
||||
// include specific files based on a RegExp
|
||||
// include: /dir/,
|
||||
// add errors to webpack instead of warnings
|
||||
failOnError: false,
|
||||
// allow import cycles that include an asyncronous import,
|
||||
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
||||
allowAsyncCycles: false,
|
||||
// set the current working directory for displaying module paths
|
||||
cwd: process.cwd(),
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
// Options similar to the same options in webpackOptions.output
|
||||
// all options are optional
|
||||
filename: argv.mode !== 'production' ? '[name].css' : '[name].[hash].css',
|
||||
chunkFilename: argv.mode !== 'production' ? '[name].css' : '[name].[hash].css',
|
||||
ignoreOrder: false, // Enable to remove warnings about conflicting order
|
||||
}),
|
||||
// new webpack.optimize.LimitChunkCountPlugin({
|
||||
// maxChunks: 1,
|
||||
// }),
|
||||
],
|
||||
performance: {
|
||||
hints: false,
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -1,108 +0,0 @@
|
||||
const merge = require('webpack-merge');
|
||||
const commonConfig = require('./common-root');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||
|
||||
function replacementWithPluginImportCode(pathToList, currentDir) {
|
||||
const fullPath = path.resolve(currentDir, pathToList || './plugins-list')
|
||||
const pluginsList = require(fullPath);
|
||||
|
||||
let code = '';
|
||||
const names = [];
|
||||
|
||||
pluginsList.forEach(plugin => {
|
||||
const name = plugin
|
||||
.split('')
|
||||
.filter(char => /[a-zA-Z]/.test(char))
|
||||
.join('');
|
||||
names.push(name);
|
||||
|
||||
code += `import ${name} from '${plugin}';\n`;
|
||||
})
|
||||
code += `
|
||||
const PLUGINS = [
|
||||
${names.map(n => ` ${n},\n`).join('')}]`;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
resolve: {
|
||||
alias: {
|
||||
"@dbeaver/core/assets": path.resolve(__dirname, "../../../core/assets"),
|
||||
|
||||
"@dbeaver/core/app": path.resolve(__dirname, "../../../core/src/app"),
|
||||
"@dbeaver/core/blocks": path.resolve(__dirname, "../../../core/src/blocks"),
|
||||
"@dbeaver/core/di": path.resolve(__dirname, "../../../core/src/di"),
|
||||
"@dbeaver/core/dialogs": path.resolve(__dirname, "../../../core/src/dialogs"),
|
||||
"@dbeaver/core/eventsLog": path.resolve(__dirname, "../../../core/src/eventsLog"),
|
||||
"@dbeaver/core/localization": path.resolve(__dirname, "../../../core/src/localization"),
|
||||
"@dbeaver/core/root": path.resolve(__dirname, "../../../core/src/root"),
|
||||
"@dbeaver/core/sdk": path.resolve(__dirname, "../../../core/src/sdk"),
|
||||
"@dbeaver/core/settings": path.resolve(__dirname, "../../../core/src/settings"),
|
||||
"@dbeaver/core/theming": path.resolve(__dirname, "../../../core/src/theming"),
|
||||
"@dbeaver/core/utils": path.resolve(__dirname, "../../../core/src/utils"),
|
||||
"@dbeaver/core/extensions": path.resolve(__dirname, "../../../core/src/extensions"),
|
||||
"@dbeaver/core/product": path.resolve(__dirname, "../../../core/src/product"),
|
||||
"@dbeaver/core/plugin": path.resolve(__dirname, "../../../core/src/plugin"),
|
||||
|
||||
react: 'preact/compat',
|
||||
react$: 'preact/compat',
|
||||
'react-dom': 'preact/compat',
|
||||
'react-dom$': 'preact/compat',
|
||||
},
|
||||
},
|
||||
context: path.resolve(__dirname, '../../src'),
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: StringReplacePlugin.replace({
|
||||
/**
|
||||
* This replacement allows to put into the build the plugins that were mentioned in package.json
|
||||
*/
|
||||
replacements: [
|
||||
{
|
||||
pattern: /const PLUGINS = \[]/ig,
|
||||
replacement: function (match, p1, offset, string) {
|
||||
return replacementWithPluginImportCode(argv.pluginsList, argv.currentDir);
|
||||
}
|
||||
}
|
||||
]})
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// new ForkTsCheckerWebpackPlugin({
|
||||
// tsconfig: path.resolve(__dirname, '../../tsconfig.json'),
|
||||
// async: false, // slow but run before dev-server starts todo try set true later
|
||||
// }),
|
||||
|
||||
/**
|
||||
* this plugin allows to resolve all @dbeaver/some-plugin packages
|
||||
*/
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
/@dbeaver\/[a-zA-z\-]*$/,
|
||||
resource => {
|
||||
resource.request = resource.request + '/src/index';
|
||||
}
|
||||
),
|
||||
|
||||
new CopyWebpackPlugin([ { from: path.resolve(argv.currentDir, './public'), to: '' } ]),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(argv.currentDir, './index.html.ejs'),
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
version: JSON.stringify(require(path.resolve(argv.currentDir, './package.json')).buildVersion),
|
||||
}),
|
||||
],
|
||||
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
// development config
|
||||
const merge = require('webpack-merge');
|
||||
const webpack = require('webpack');
|
||||
const commonConfig = require('./common-exp');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode || 'development',
|
||||
entry: [
|
||||
// 'react-hot-loader/patch', // activate HMR for React
|
||||
'webpack-dev-server/client?http://localhost:3100',// bundle the client for webpack-dev-server and connect to the provided endpoint
|
||||
// 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates
|
||||
'./index.js' // the entry point of our app
|
||||
],
|
||||
devServer: {
|
||||
hot: false, // enable HMR on the server
|
||||
proxy: {
|
||||
'/dbeaver': {
|
||||
target: argv.server || 'localhost:3100'
|
||||
}
|
||||
}
|
||||
},
|
||||
// devtool: 'cheap-module-eval-source-map',
|
||||
plugins: [
|
||||
// new webpack.HotModuleReplacementPlugin(), // enable HMR globally
|
||||
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
|
||||
],
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
// development config
|
||||
const merge = require('webpack-merge');
|
||||
const webpack = require('webpack');
|
||||
const commonConfig = require('./common');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode || 'development',
|
||||
entry: [
|
||||
// 'react-hot-loader/patch', // activate HMR for React
|
||||
'webpack-dev-server/client?http://localhost:3100',// bundle the client for webpack-dev-server and connect to the provided endpoint
|
||||
// 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates
|
||||
'./index.ts' // the entry point of our app
|
||||
],
|
||||
devServer: {
|
||||
hot: true, // enable HMR on the server
|
||||
proxy: {
|
||||
'/dbeaver': {
|
||||
target: argv.server || 'localhost:3100'
|
||||
}
|
||||
},
|
||||
stats: {
|
||||
colors: true,
|
||||
},
|
||||
},
|
||||
devtool: 'cheap-module-eval-source-map',
|
||||
plugins: [
|
||||
// new webpack.HotModuleReplacementPlugin(), // enable HMR globally
|
||||
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
|
||||
],
|
||||
});
|
||||
@@ -1,22 +0,0 @@
|
||||
// production config
|
||||
const merge = require('webpack-merge');
|
||||
const {resolve} = require('path');
|
||||
|
||||
const commonConfig = require('./common-exp');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode || 'development',
|
||||
entry: './index.js',
|
||||
output: {
|
||||
filename: 'js/bundle.[hash].js',
|
||||
path: resolve(argv.currentDir, './dist'),
|
||||
publicPath: '',
|
||||
},
|
||||
devtool: 'source-map',
|
||||
plugins: [],
|
||||
optimization: {
|
||||
minimize: false,
|
||||
namedModules: true,
|
||||
concatenateModules: false,
|
||||
},
|
||||
});
|
||||
@@ -1,22 +0,0 @@
|
||||
// production config
|
||||
const merge = require('webpack-merge');
|
||||
const {resolve} = require('path');
|
||||
|
||||
const commonConfig = require('./common');
|
||||
|
||||
module.exports = (env, argv) => merge(commonConfig(env, argv), {
|
||||
mode: argv.mode || 'development',
|
||||
entry: './index.ts',
|
||||
output: {
|
||||
filename: 'js/bundle.[hash].min.js',
|
||||
path: resolve(argv.currentDir, './dist'),
|
||||
publicPath: '',
|
||||
},
|
||||
devtool: 'source-map',
|
||||
plugins: [],
|
||||
optimization: {
|
||||
minimize: true,
|
||||
namedModules: false,
|
||||
concatenateModules: true,
|
||||
},
|
||||
});
|
||||
@@ -7,7 +7,7 @@
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"build:analyze": "echo \"no analyze specified\" && exit 0",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -4,15 +4,10 @@
|
||||
"description": "",
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js --mode=production",
|
||||
"build-exp": "npm run clean-dist && webpack -p --config=configs/webpack/exp.js --mode=development",
|
||||
"build-exp2": "npm run clean-dist && builder build-app",
|
||||
"build": "npm run clean-dist && builder build-app",
|
||||
"serve": "builder serve-app",
|
||||
"build:analyze": "echo \"no analyze specified\" && exit 0",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"dev": "webpack-dev-server --progress --config=configs/webpack/dev.js --port=3100",
|
||||
"dev-exp": "webpack-dev-server --progress --config=configs/webpack/dev-exp.js --port=3100",
|
||||
"dev-exp2": "builder serve-app",
|
||||
"dev-exp3": "builder serve-app-old",
|
||||
"gql:gen": "graphql-codegen",
|
||||
"gql:gen:dev": "graphql-codegen --watch",
|
||||
"lint": "eslint ./src/ --ext .ts,.tsx",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/types",
|
||||
"scripts": {
|
||||
"build-plugin": "npm run clean-dist && builder build-plugin",
|
||||
"build": "npm run clean-dist && builder build-plugin",
|
||||
"serve-plugin": "builder serve-plugin",
|
||||
"clean-dist": "rimraf dist/*",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
Reference in New Issue
Block a user