2019-01-02 04:24:12 -06:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2023-01-02 00:23:55 -06:00
|
|
|
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
2019-01-02 04:24:12 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-12 10:51:54 -05:00
|
|
|
/* eslint-env node */
|
2017-07-20 06:52:15 -05:00
|
|
|
// Import file, libraries and plugins
|
2017-07-18 09:13:16 -05:00
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
2018-09-04 05:24:51 -05:00
|
|
|
const fs = require('fs');
|
2017-07-20 06:52:15 -05:00
|
|
|
const sourceDir = __dirname + '/pgadmin/static';
|
|
|
|
// webpack.shim.js contains path references for resolve > alias configuration
|
|
|
|
// and other util function used in CommonsChunksPlugin.
|
2017-07-18 09:13:16 -05:00
|
|
|
const webpackShimConfig = require('./webpack.shim');
|
|
|
|
const PRODUCTION = process.env.NODE_ENV === 'production';
|
2021-02-10 01:17:52 -06:00
|
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
2019-12-11 02:32:27 -06:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2019-03-14 10:11:16 -05:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const extractStyle = new MiniCssExtractPlugin({
|
2019-01-03 08:43:45 -06:00
|
|
|
filename: '[name].css',
|
2019-11-07 07:21:03 -06:00
|
|
|
chunkFilename: '[name].css',
|
2019-01-03 08:43:45 -06:00
|
|
|
});
|
2019-10-10 01:35:28 -05:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2019-11-07 07:21:03 -06:00
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2021-02-10 01:17:52 -06:00
|
|
|
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
|
2019-10-10 01:35:28 -05:00
|
|
|
|
Improvement in the look and feel of the whole application
Changed the SCSS/CSS for the below third party libraries to adopt the
new look 'n' feel:
- wcDocker
- Alertify dialogs, and notifications
- AciTree
- Bootstrap Navbar
- Bootstrap Tabs
- Bootstrap Drop-Down menu
- Backgrid
- Select2
Adopated the new the look 'n' feel for the dialogs, wizard, properties,
tab panels, tabs, fieldset, subnode control, spinner control, HTML
table, and other form controls.
- Font is changed to Roboto
- Using SCSS variables to define the look 'n' feel
- Designer background images for the Login, and Forget password pages in
'web' mode
- Improved the look 'n' feel for the key selection in the preferences
dialog
- Table classes consistency changes across the application
- File Open and Save dialog list view changes
Author(s): Aditya Toshniwal & Khushboo Vashi
2018-12-21 05:44:55 -06:00
|
|
|
const envType = PRODUCTION ? 'production': 'development';
|
2019-04-30 07:57:10 -05:00
|
|
|
const devToolVal = PRODUCTION ? false : 'eval';
|
2019-10-10 01:35:28 -05:00
|
|
|
const analyzerMode = process.env.ANALYZE=='true' ? 'static' : 'disabled';
|
2017-07-18 09:13:16 -05:00
|
|
|
|
2019-11-07 07:21:03 -06:00
|
|
|
const outputPath = __dirname + '/pgadmin/static/js/generated';
|
2019-11-11 07:17:43 -06:00
|
|
|
const pgadminThemesJson = __dirname + '/pgadmin/misc/themes/pgadmin.themes.json';
|
2019-11-07 07:21:03 -06:00
|
|
|
|
2017-07-20 06:52:15 -05:00
|
|
|
// Expose libraries in app context so they need not to
|
|
|
|
// require('libname') when used in a module
|
2017-07-18 09:13:16 -05:00
|
|
|
const providePlugin = new webpack.ProvidePlugin({
|
2022-11-20 23:24:15 -06:00
|
|
|
_: 'lodash',
|
2023-10-23 07:13:17 -05:00
|
|
|
pgAdmin: 'sources/pgadmin',
|
2018-10-11 07:23:59 -05:00
|
|
|
'moment': 'moment',
|
|
|
|
'window.moment':'moment',
|
2021-02-19 02:59:43 -06:00
|
|
|
process: 'process/browser',
|
2023-06-30 05:38:33 -05:00
|
|
|
Buffer: ['buffer', 'Buffer']
|
2017-07-18 09:13:16 -05:00
|
|
|
});
|
|
|
|
|
2017-08-09 06:00:30 -05:00
|
|
|
// Helps in debugging each single file, it extracts the module files
|
|
|
|
// from bundle so that they are accessible by search in Chrome's sources panel.
|
|
|
|
// Reference: https://webpack.js.org/plugins/source-map-dev-tool-plugin/#components/sidebar/sidebar.jsx
|
|
|
|
const sourceMapDevToolPlugin = new webpack.SourceMapDevToolPlugin({
|
|
|
|
filename: '[name].js.map',
|
2022-09-07 08:50:03 -05:00
|
|
|
exclude: /(vendor|codemirror|pgadmin\.js|pgadmin.theme|pgadmin.static|style\.js|popper)/,
|
2017-08-09 06:00:30 -05:00
|
|
|
columns: false,
|
|
|
|
});
|
|
|
|
|
2019-10-10 01:35:28 -05:00
|
|
|
// can be enabled using bundle:analyze
|
|
|
|
const bundleAnalyzer = new BundleAnalyzerPlugin({
|
|
|
|
analyzerMode: analyzerMode,
|
|
|
|
reportFilename: 'analyze_report.html',
|
|
|
|
});
|
2018-10-10 06:43:26 -05:00
|
|
|
|
2021-02-10 01:17:52 -06:00
|
|
|
const copyFiles = new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
pgadminThemesJson,
|
|
|
|
{
|
|
|
|
from: './pgadmin/static/scss/resources/**/*.png',
|
2023-06-12 04:29:43 -05:00
|
|
|
to: 'img/[name][ext]',
|
2021-02-10 01:17:52 -06:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2018-10-10 06:43:26 -05:00
|
|
|
function cssToBeSkiped(curr_path) {
|
|
|
|
/** Skip all templates **/
|
|
|
|
if(curr_path.indexOf('template') > -1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-18 03:19:54 -06:00
|
|
|
for(let value of webpackShimConfig.css_bundle_skip) {
|
|
|
|
if(path.join(__dirname, value) === curr_path){
|
2018-10-10 06:43:26 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-04 05:24:51 -05:00
|
|
|
/* Get all the style files recursively and store in array to
|
2018-10-10 06:43:26 -05:00
|
|
|
* give input to webpack.
|
2018-09-04 05:24:51 -05:00
|
|
|
*/
|
2019-11-07 07:21:03 -06:00
|
|
|
function pushModulesStyles(curr_path, pgadminStyles, extn) {
|
2018-10-10 06:43:26 -05:00
|
|
|
/** Skip Directories */
|
|
|
|
if(cssToBeSkiped(curr_path)) {
|
2018-09-04 05:24:51 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.readdirSync(curr_path).map(function(curr_file) {
|
2018-10-10 06:43:26 -05:00
|
|
|
/** Skip Files */
|
|
|
|
if(cssToBeSkiped(path.join(curr_path, curr_file))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-04 05:24:51 -05:00
|
|
|
let stats = fs.statSync(path.join(curr_path, curr_file));
|
|
|
|
/* if directory, dig further */
|
|
|
|
if(stats.isDirectory()) {
|
2019-11-07 07:21:03 -06:00
|
|
|
pushModulesStyles(path.join(curr_path, curr_file), pgadminStyles, extn);
|
2018-09-04 05:24:51 -05:00
|
|
|
}
|
2019-11-07 07:21:03 -06:00
|
|
|
else if(stats.isFile() && (curr_file.endsWith(extn))) {
|
2018-09-04 05:24:51 -05:00
|
|
|
pgadminStyles.push(path.join(curr_path, curr_file));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-10-10 06:43:26 -05:00
|
|
|
|
2019-11-07 07:21:03 -06:00
|
|
|
let pgadminScssStyles = [];
|
|
|
|
let pgadminCssStyles = [];
|
|
|
|
|
2018-10-10 06:43:26 -05:00
|
|
|
/* Include what is given in shim config */
|
2022-01-18 03:19:54 -06:00
|
|
|
for(let value of webpackShimConfig.css_bundle_include) {
|
|
|
|
if(value.endsWith('.scss')) {
|
|
|
|
pgadminScssStyles.push(path.join(__dirname, value));
|
|
|
|
} else if(value.endsWith('.css')){
|
|
|
|
pgadminCssStyles.push(path.join(__dirname, value));
|
2019-11-07 07:21:03 -06:00
|
|
|
}
|
2018-10-10 06:43:26 -05:00
|
|
|
}
|
2018-09-04 05:24:51 -05:00
|
|
|
|
2019-11-07 07:21:03 -06:00
|
|
|
pushModulesStyles(path.join(__dirname,'./pgadmin'), pgadminScssStyles, '.scss');
|
|
|
|
pushModulesStyles(path.join(__dirname,'./pgadmin'), pgadminCssStyles, '.css');
|
2021-02-10 01:17:52 -06:00
|
|
|
pgadminCssStyles.push(path.join(__dirname,'./pgadmin/static/js/pgadmin.fonticon.js'));
|
2019-11-07 07:21:03 -06:00
|
|
|
|
|
|
|
/* Get all the themes */
|
|
|
|
|
|
|
|
let all_themes_dir = path.join(__dirname,'./pgadmin/static/scss/resources');
|
|
|
|
let pgadminThemes = {};
|
|
|
|
/* Read all the theme dirs */
|
|
|
|
/* Theme format
|
|
|
|
"theme_name": {
|
|
|
|
"disp_name": "theme_name",
|
|
|
|
"cssfile": "pgadmin.theme.theme_name",
|
|
|
|
"preview_img": "theme_name_preview.png"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
fs.readdirSync(all_themes_dir).map(function(curr_dir) {
|
|
|
|
let stats = fs.statSync(path.join(all_themes_dir, curr_dir));
|
|
|
|
|
|
|
|
if(stats.isDirectory()) {
|
|
|
|
/* Theme directory found */
|
2021-02-10 02:16:42 -06:00
|
|
|
let cssfile = 'pgadmin.theme.'+curr_dir;
|
2020-07-20 01:21:21 -05:00
|
|
|
|
|
|
|
let disp_name = curr_dir;
|
|
|
|
|
2019-11-07 07:21:03 -06:00
|
|
|
pgadminThemes[curr_dir] = {
|
|
|
|
/* For now lets keep it as beta release */
|
2020-07-20 01:21:21 -05:00
|
|
|
disp_name: disp_name,
|
2019-11-07 07:21:03 -06:00
|
|
|
cssfile: cssfile,
|
|
|
|
preview_img: curr_dir + '_preview.png',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
fs.writeFileSync(pgadminThemesJson, JSON.stringify(pgadminThemes, null, 4));
|
|
|
|
|
2022-09-08 07:38:58 -05:00
|
|
|
let themeCssRules = function(theme_name) {
|
2019-11-07 07:21:03 -06:00
|
|
|
return [{
|
2022-02-10 23:06:24 -06:00
|
|
|
test: /\.svg$/,
|
|
|
|
oneOf: [
|
|
|
|
{
|
|
|
|
issuer: /\.[jt]sx?$/,
|
|
|
|
resourceQuery: /svgr/,
|
|
|
|
use: ['@svgr/webpack'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'asset',
|
|
|
|
parser: {
|
|
|
|
dataUrlCondition: {
|
|
|
|
maxSize: 4 * 1024, // 4kb
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},{
|
|
|
|
test: /\.(jpe?g|png|gif)$/i,
|
2021-02-10 01:17:52 -06:00
|
|
|
type: 'asset',
|
|
|
|
parser: {
|
|
|
|
dataUrlCondition: {
|
|
|
|
maxSize: 4 * 1024, // 4kb
|
2019-11-07 07:21:03 -06:00
|
|
|
},
|
2021-02-10 01:17:52 -06:00
|
|
|
},
|
|
|
|
generator: {
|
|
|
|
filename: 'img/[name].[ext]',
|
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
exclude: /vendor/,
|
2021-09-27 06:14:26 -05:00
|
|
|
},{
|
2022-02-10 23:06:24 -06:00
|
|
|
test: /\.(eot|ttf|woff|woff2)$/,
|
2021-02-10 01:17:52 -06:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'fonts/[name].[ext]',
|
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
include: [
|
|
|
|
/node_modules/,
|
|
|
|
path.join(sourceDir, '/css/'),
|
|
|
|
path.join(sourceDir, '/scss/'),
|
|
|
|
path.join(sourceDir, '/fonts/'),
|
|
|
|
],
|
|
|
|
exclude: /vendor/,
|
2021-09-27 06:14:26 -05:00
|
|
|
},{
|
2019-11-07 07:21:03 -06:00
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
2021-02-10 01:17:52 -06:00
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
publicPath: '',
|
|
|
|
},
|
|
|
|
},
|
2021-09-27 06:14:26 -05:00
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
url: false,
|
|
|
|
sourceMap: true,
|
|
|
|
},
|
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
2021-02-10 01:17:52 -06:00
|
|
|
postcssOptions: () =>({
|
|
|
|
plugins: [
|
|
|
|
require('autoprefixer')(),
|
|
|
|
],
|
|
|
|
}),
|
2019-11-07 07:21:03 -06:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{loader: 'sass-loader'},
|
|
|
|
{
|
|
|
|
loader: 'sass-resources-loader',
|
|
|
|
options: {
|
2020-07-16 09:23:39 -05:00
|
|
|
resources: function(_theme_name){
|
2019-11-07 07:21:03 -06:00
|
|
|
let ret_res = [
|
|
|
|
'./pgadmin/static/scss/resources/pgadmin.resources.scss',
|
|
|
|
];
|
2020-07-16 09:23:39 -05:00
|
|
|
if(_theme_name!='standard') {
|
|
|
|
ret_res.unshift('./pgadmin/static/scss/resources/' + _theme_name + '/_theme.variables.scss');
|
2019-11-07 07:21:03 -06:00
|
|
|
}
|
|
|
|
return ret_res;
|
|
|
|
}(theme_name),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}, {
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
2021-02-10 01:17:52 -06:00
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
publicPath: '',
|
|
|
|
},
|
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
2021-02-10 01:17:52 -06:00
|
|
|
postcssOptions: () =>({
|
|
|
|
plugins: [
|
|
|
|
require('autoprefixer')(),
|
|
|
|
],
|
|
|
|
}),
|
2019-11-07 07:21:03 -06:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
2022-09-08 07:38:58 -05:00
|
|
|
let getThemeWebpackConfig = function(theme_name) {
|
2019-11-07 07:21:03 -06:00
|
|
|
return {
|
|
|
|
mode: envType,
|
|
|
|
devtool: devToolVal,
|
|
|
|
stats: { children: false },
|
|
|
|
// The base directory, an absolute path, for resolving entry points and loaders
|
|
|
|
// from configuration.
|
|
|
|
context: __dirname,
|
|
|
|
// Specify entry points of application
|
|
|
|
entry: {
|
|
|
|
[pgadminThemes[theme_name].cssfile]: pgadminScssStyles,
|
|
|
|
},
|
|
|
|
// path: The output directory for generated bundles(defined in entry)
|
|
|
|
// Ref: https://webpack.js.org/configuration/output/#output-library
|
|
|
|
output: {
|
|
|
|
libraryTarget: 'amd',
|
|
|
|
path: outputPath,
|
|
|
|
filename: '[name].js',
|
|
|
|
libraryExport: 'default',
|
2021-02-10 01:17:52 -06:00
|
|
|
publicPath: '',
|
2019-11-07 07:21:03 -06:00
|
|
|
},
|
|
|
|
// Templates files which contains python code needs to load dynamically
|
|
|
|
// Such files specified in externals are loaded at first and defined in
|
|
|
|
// the start of generated bundle within define(['libname'],fn) etc.
|
|
|
|
externals: webpackShimConfig.externals,
|
|
|
|
module: {
|
|
|
|
// References:
|
|
|
|
// Module and Rules: https://webpack.js.org/configuration/module/
|
|
|
|
// Loaders: https://webpack.js.org/loaders/
|
|
|
|
//
|
|
|
|
rules: themeCssRules(theme_name),
|
|
|
|
},
|
2021-02-10 01:17:52 -06:00
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [
|
|
|
|
new CssMinimizerPlugin({
|
|
|
|
minimizerOptions: {
|
|
|
|
preset: [
|
|
|
|
'default',
|
|
|
|
{
|
|
|
|
discardComments: { removeAll: true },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
resolve: {
|
|
|
|
alias: webpackShimConfig.resolveAlias,
|
|
|
|
modules: ['node_modules', '.'],
|
|
|
|
extensions: ['.js'],
|
|
|
|
unsafeCache: true,
|
2022-05-23 05:34:21 -05:00
|
|
|
fallback: {
|
|
|
|
'fs': false
|
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
},
|
|
|
|
// Watch mode Configuration: After initial build, webpack will watch for
|
|
|
|
// changes in files and compiles only files which are changed,
|
|
|
|
// if watch is set to True
|
|
|
|
// Reference: https://webpack.js.org/configuration/watch/#components/sidebar/sidebar.jsx
|
|
|
|
watchOptions: {
|
|
|
|
aggregateTimeout: 300,
|
|
|
|
poll: 1000,
|
|
|
|
ignored: /node_modules/,
|
|
|
|
},
|
|
|
|
// Define list of Plugins used in Production or development mode
|
|
|
|
// Ref:https://webpack.js.org/concepts/plugins/#components/sidebar/sidebar.jsx
|
2021-02-10 06:07:02 -06:00
|
|
|
plugins: [
|
2019-11-07 07:21:03 -06:00
|
|
|
extractStyle,
|
|
|
|
sourceMapDevToolPlugin,
|
2021-02-10 06:07:02 -06:00
|
|
|
]
|
2019-11-07 07:21:03 -06:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-08 07:38:58 -05:00
|
|
|
let pgadminThemesWebpack = [];
|
2021-05-29 02:25:59 -05:00
|
|
|
Object.keys(pgadminThemes).forEach((theme_name)=>{
|
2019-11-07 07:21:03 -06:00
|
|
|
pgadminThemesWebpack.push(getThemeWebpackConfig(theme_name));
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = [{
|
2019-03-14 10:11:16 -05:00
|
|
|
mode: envType,
|
2019-04-30 07:57:10 -05:00
|
|
|
devtool: devToolVal,
|
2021-02-10 01:17:52 -06:00
|
|
|
stats: { children: false, builtAt: true, chunks: true, timings: true },
|
2017-07-20 06:52:15 -05:00
|
|
|
// The base directory, an absolute path, for resolving entry points and loaders
|
|
|
|
// from configuration.
|
2017-07-18 09:13:16 -05:00
|
|
|
context: __dirname,
|
2017-07-20 06:52:15 -05:00
|
|
|
// Specify entry points of application
|
2017-06-13 03:50:41 -05:00
|
|
|
entry: {
|
2017-07-18 09:13:16 -05:00
|
|
|
'app.bundle': sourceDir + '/bundle/app.js',
|
|
|
|
codemirror: sourceDir + '/bundle/codemirror.js',
|
2023-06-30 05:38:33 -05:00
|
|
|
'security.pages': 'security.pages',
|
2022-04-07 07:06:56 -05:00
|
|
|
sqleditor: './pgadmin/tools/sqleditor/static/js/index.js',
|
2022-09-07 08:50:03 -05:00
|
|
|
schema_diff: './pgadmin/tools/schema_diff/static/js/index.js',
|
2022-09-06 07:39:13 -05:00
|
|
|
erd_tool: './pgadmin/tools/erd/static/js/index.js',
|
2021-05-25 09:42:57 -05:00
|
|
|
psql_tool: './pgadmin/tools/psql/static/js/index.js',
|
2022-06-20 08:35:26 -05:00
|
|
|
debugger: './pgadmin/tools/debugger/static/js/index.js',
|
2019-11-07 07:21:03 -06:00
|
|
|
'pgadmin.style': pgadminCssStyles,
|
|
|
|
pgadmin: pgadminScssStyles,
|
2018-09-04 05:24:51 -05:00
|
|
|
style: './pgadmin/static/css/style.css',
|
2017-06-13 03:50:41 -05:00
|
|
|
},
|
2017-07-20 06:52:15 -05:00
|
|
|
// path: The output directory for generated bundles(defined in entry)
|
|
|
|
// Ref: https://webpack.js.org/configuration/output/#output-library
|
2017-06-12 10:51:54 -05:00
|
|
|
output: {
|
|
|
|
libraryTarget: 'amd',
|
2019-11-07 07:21:03 -06:00
|
|
|
path: outputPath,
|
2017-06-13 03:50:41 -05:00
|
|
|
filename: '[name].js',
|
2021-05-11 03:18:53 -05:00
|
|
|
chunkFilename: '[name].chunk.js?id=[chunkhash]',
|
2017-07-18 09:13:16 -05:00
|
|
|
libraryExport: 'default',
|
2021-02-10 01:17:52 -06:00
|
|
|
publicPath: '',
|
2017-07-18 09:13:16 -05:00
|
|
|
},
|
2017-07-20 06:52:15 -05:00
|
|
|
// Templates files which contains python code needs to load dynamically
|
|
|
|
// Such files specified in externals are loaded at first and defined in
|
|
|
|
// the start of generated bundle within define(['libname'],fn) etc.
|
2017-07-27 06:55:07 -05:00
|
|
|
externals: webpackShimConfig.externals,
|
2017-06-12 10:51:54 -05:00
|
|
|
module: {
|
2017-07-20 06:52:15 -05:00
|
|
|
// References:
|
|
|
|
// Module and Rules: https://webpack.js.org/configuration/module/
|
|
|
|
// Loaders: https://webpack.js.org/loaders/
|
|
|
|
//
|
|
|
|
// imports-loader: it adds dependent modules(use:imports-loader?module1)
|
2023-10-23 07:13:17 -05:00
|
|
|
// at the beginning of module it is dependency.
|
2017-07-20 06:52:15 -05:00
|
|
|
// It solves number of problems
|
|
|
|
// Ref: http:/github.com/webpack-contrib/imports-loader/
|
2017-06-12 10:51:54 -05:00
|
|
|
rules: [{
|
2021-02-10 01:17:52 -06:00
|
|
|
test: /\.fonticon\.js/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
url: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'webfonts-loader',
|
|
|
|
],
|
|
|
|
},{
|
2020-07-29 04:19:22 -05:00
|
|
|
test: /\.jsx?$/,
|
2017-06-13 03:50:41 -05:00
|
|
|
exclude: [/node_modules/, /vendor/],
|
2017-06-12 10:51:54 -05:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
2021-09-27 06:14:26 -05:00
|
|
|
},
|
2022-10-03 00:48:22 -05:00
|
|
|
},{
|
|
|
|
test: /\.m?js$/,
|
|
|
|
resolve: {
|
|
|
|
fullySpecified: false
|
|
|
|
},
|
|
|
|
},{
|
2021-09-27 06:14:26 -05:00
|
|
|
test: /\.tsx?$|\.ts?$/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [['@babel/preset-env', {'modules': 'commonjs', 'useBuiltIns': 'usage', 'corejs': 3}], '@babel/preset-react', '@babel/preset-typescript'],
|
|
|
|
plugins: ['@babel/plugin-proposal-class-properties', '@babel/proposal-object-rest-spread'],
|
2017-06-12 10:51:54 -05:00
|
|
|
},
|
|
|
|
},
|
2018-03-02 10:49:25 -06:00
|
|
|
}, {
|
|
|
|
test: /external_table.*\.js/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
2019-10-10 01:35:28 -05:00
|
|
|
presets: [['@babel/preset-env', {'modules': 'commonjs', 'useBuiltIns': 'usage', 'corejs': 3}]],
|
2018-03-02 10:49:25 -06:00
|
|
|
},
|
|
|
|
},
|
2017-06-23 03:35:56 -05:00
|
|
|
}, {
|
2017-07-20 06:52:15 -05:00
|
|
|
// Transforms the code in a way that it works in the webpack environment.
|
|
|
|
// It uses imports-loader internally to load dependency. Its
|
|
|
|
// configuration is specified in webpack.shim.js
|
|
|
|
// Ref: https://www.npmjs.com/package/shim-loader
|
2017-07-18 09:13:16 -05:00
|
|
|
test: /\.js/,
|
2018-03-02 10:49:25 -06:00
|
|
|
exclude: [/external_table/],
|
2017-07-18 09:13:16 -05:00
|
|
|
loader: 'shim-loader',
|
2021-02-10 01:17:52 -06:00
|
|
|
options: webpackShimConfig,
|
2017-07-18 09:13:16 -05:00
|
|
|
include: path.join(__dirname, '/pgadmin/browser'),
|
|
|
|
}, {
|
2020-07-29 04:19:22 -05:00
|
|
|
// imports-loader: it adds dependent modules(use:imports-loader?module1)
|
2023-10-23 07:13:17 -05:00
|
|
|
// at the beginning of module it is dependency.
|
2020-07-29 04:19:22 -05:00
|
|
|
// It solves number of problems
|
|
|
|
// Ref: http:/github.com/webpack-contrib/imports-loader/
|
2022-04-07 07:06:56 -05:00
|
|
|
test: require.resolve('./pgadmin/tools/sqleditor/static/js/index'),
|
2017-07-18 09:13:16 -05:00
|
|
|
use: {
|
2021-02-10 01:17:52 -06:00
|
|
|
loader: 'imports-loader',
|
|
|
|
options: {
|
|
|
|
type: 'commonjs',
|
|
|
|
imports: [
|
|
|
|
'pure|pgadmin.tools.user_management',
|
2022-08-11 00:19:45 -05:00
|
|
|
'pure|pgadmin.browser.bgprocessmanager',
|
2021-02-10 01:17:52 -06:00
|
|
|
'pure|pgadmin.node.server_group',
|
|
|
|
'pure|pgadmin.node.server',
|
|
|
|
'pure|pgadmin.node.database',
|
|
|
|
'pure|pgadmin.node.role',
|
|
|
|
'pure|pgadmin.node.cast',
|
|
|
|
'pure|pgadmin.node.publication',
|
|
|
|
'pure|pgadmin.node.subscription',
|
|
|
|
'pure|pgadmin.node.tablespace',
|
|
|
|
'pure|pgadmin.node.resource_group',
|
|
|
|
'pure|pgadmin.node.event_trigger',
|
|
|
|
'pure|pgadmin.node.extension',
|
|
|
|
'pure|pgadmin.node.language',
|
|
|
|
'pure|pgadmin.node.foreign_data_wrapper',
|
|
|
|
'pure|pgadmin.node.foreign_server',
|
|
|
|
'pure|pgadmin.node.user_mapping',
|
|
|
|
'pure|pgadmin.node.schema',
|
|
|
|
'pure|pgadmin.node.catalog',
|
2023-09-26 04:33:03 -05:00
|
|
|
'pure|pgadmin.node.foreign_table_column',
|
2021-02-10 01:17:52 -06:00
|
|
|
'pure|pgadmin.node.catalog_object',
|
|
|
|
'pure|pgadmin.node.collation',
|
|
|
|
'pure|pgadmin.node.domain',
|
|
|
|
'pure|pgadmin.node.domain_constraints',
|
|
|
|
'pure|pgadmin.node.foreign_table',
|
|
|
|
'pure|pgadmin.node.fts_configuration',
|
|
|
|
'pure|pgadmin.node.fts_dictionary',
|
|
|
|
'pure|pgadmin.node.fts_parser',
|
|
|
|
'pure|pgadmin.node.fts_template',
|
|
|
|
'pure|pgadmin.node.function',
|
|
|
|
'pure|pgadmin.node.procedure',
|
|
|
|
'pure|pgadmin.node.edbfunc',
|
|
|
|
'pure|pgadmin.node.edbproc',
|
|
|
|
'pure|pgadmin.node.edbvar',
|
|
|
|
'pure|pgadmin.node.trigger_function',
|
|
|
|
'pure|pgadmin.node.package',
|
|
|
|
'pure|pgadmin.node.sequence',
|
|
|
|
'pure|pgadmin.node.synonym',
|
|
|
|
'pure|pgadmin.node.type',
|
|
|
|
'pure|pgadmin.node.rule',
|
|
|
|
'pure|pgadmin.node.index',
|
|
|
|
'pure|pgadmin.node.row_security_policy',
|
|
|
|
'pure|pgadmin.node.trigger',
|
|
|
|
'pure|pgadmin.node.catalog_object_column',
|
|
|
|
'pure|pgadmin.node.view',
|
|
|
|
'pure|pgadmin.node.mview',
|
|
|
|
'pure|pgadmin.node.table',
|
|
|
|
'pure|pgadmin.node.partition',
|
|
|
|
'pure|pgadmin.node.compound_trigger',
|
2021-10-29 05:44:33 -05:00
|
|
|
'pure|pgadmin.node.aggregate',
|
|
|
|
'pure|pgadmin.node.operator',
|
2021-02-10 01:17:52 -06:00
|
|
|
],
|
|
|
|
},
|
2017-07-18 09:13:16 -05:00
|
|
|
},
|
2021-05-25 09:42:57 -05:00
|
|
|
},{
|
2017-07-18 09:13:16 -05:00
|
|
|
test: require.resolve('./pgadmin/static/bundle/browser'),
|
|
|
|
use: {
|
2021-02-10 01:17:52 -06:00
|
|
|
loader: 'imports-loader',
|
|
|
|
options: {
|
|
|
|
type: 'commonjs',
|
|
|
|
imports: [
|
|
|
|
'pure|pgadmin.about',
|
|
|
|
'pure|pgadmin.preferences',
|
|
|
|
'pure|pgadmin.settings',
|
|
|
|
'pure|pgadmin.tools.backup',
|
|
|
|
'pure|pgadmin.tools.restore',
|
|
|
|
'pure|pgadmin.tools.grant_wizard',
|
|
|
|
'pure|pgadmin.tools.maintenance',
|
|
|
|
'pure|pgadmin.tools.import_export',
|
2022-01-04 00:57:17 -06:00
|
|
|
'pure|pgadmin.tools.import_export_servers',
|
2022-06-15 01:07:54 -05:00
|
|
|
'pure|pgadmin.tools.debugger',
|
2021-02-10 01:17:52 -06:00
|
|
|
'pure|pgadmin.node.pga_job',
|
|
|
|
'pure|pgadmin.tools.schema_diff',
|
2022-07-19 04:57:47 -05:00
|
|
|
'pure|pgadmin.tools.file_manager',
|
2021-02-10 01:17:52 -06:00
|
|
|
'pure|pgadmin.tools.search_objects',
|
2022-09-06 07:39:13 -05:00
|
|
|
'pure|pgadmin.tools.erd',
|
2021-05-25 09:42:57 -05:00
|
|
|
'pure|pgadmin.tools.psql_module',
|
2022-04-07 07:06:56 -05:00
|
|
|
'pure|pgadmin.tools.sqleditor',
|
2022-02-14 00:43:48 -06:00
|
|
|
'pure|pgadmin.misc.cloud',
|
2021-02-10 01:17:52 -06:00
|
|
|
],
|
|
|
|
},
|
2017-07-18 09:13:16 -05:00
|
|
|
},
|
2019-11-07 07:21:03 -06:00
|
|
|
}].concat(themeCssRules('standard')),
|
2017-07-20 06:52:15 -05:00
|
|
|
// Prevent module from parsing through webpack, helps in reducing build time
|
2017-07-18 09:13:16 -05:00
|
|
|
noParse: [/moment.js/],
|
2017-06-12 10:51:54 -05:00
|
|
|
},
|
|
|
|
resolve: {
|
2017-07-18 09:13:16 -05:00
|
|
|
alias: webpackShimConfig.resolveAlias,
|
|
|
|
modules: ['node_modules', '.'],
|
2021-09-27 06:14:26 -05:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
2017-07-18 09:13:16 -05:00
|
|
|
unsafeCache: true,
|
2022-05-23 05:34:21 -05:00
|
|
|
fallback: {
|
|
|
|
'fs': false
|
|
|
|
},
|
2017-06-12 10:51:54 -05:00
|
|
|
},
|
2017-08-25 06:54:46 -05:00
|
|
|
// Watch mode Configuration: After initial build, webpack will watch for
|
|
|
|
// changes in files and compiles only files which are changed,
|
|
|
|
// if watch is set to True
|
|
|
|
// Reference: https://webpack.js.org/configuration/watch/#components/sidebar/sidebar.jsx
|
|
|
|
watchOptions: {
|
|
|
|
aggregateTimeout: 300,
|
|
|
|
poll: 1000,
|
|
|
|
ignored: /node_modules/,
|
|
|
|
},
|
2019-03-14 10:11:16 -05:00
|
|
|
optimization: {
|
2023-06-09 07:52:20 -05:00
|
|
|
minimizer: PRODUCTION ? [
|
2019-12-11 02:32:27 -06:00
|
|
|
new TerserPlugin({
|
2023-07-20 06:51:47 -05:00
|
|
|
parallel: false,
|
2021-02-10 01:17:52 -06:00
|
|
|
extractComments: true,
|
2019-12-11 02:32:27 -06:00
|
|
|
terserOptions: {
|
2019-10-10 01:35:28 -05:00
|
|
|
compress: true,
|
2019-03-14 10:11:16 -05:00
|
|
|
},
|
|
|
|
}),
|
2023-06-09 07:52:20 -05:00
|
|
|
new ImageMinimizerPlugin({
|
|
|
|
test: /\.(jpe?g|png|gif)$/i,
|
|
|
|
minimizer: {
|
|
|
|
implementation: ImageMinimizerPlugin.imageminMinify,
|
|
|
|
options: {
|
|
|
|
plugins: [
|
2023-06-09 08:26:03 -05:00
|
|
|
['mozjpeg', { progressive: true }],
|
|
|
|
['optipng', { optimizationLevel: 7 }],
|
2023-06-09 07:52:20 -05:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
] : [],
|
2019-03-14 10:11:16 -05:00
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
2023-10-27 05:21:45 -05:00
|
|
|
vendor_sqleditor: {
|
|
|
|
name: 'vendor_sqleditor',
|
|
|
|
filename: 'vendor.sqleditor.js',
|
|
|
|
chunks: 'all',
|
|
|
|
reuseExistingChunk: true,
|
|
|
|
priority: 9,
|
|
|
|
minChunks: 2,
|
|
|
|
enforce: true,
|
|
|
|
test(module) {
|
|
|
|
return webpackShimConfig.matchModules(module, ['jsoneditor', 'leaflet']);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
vendor_react: {
|
|
|
|
name: 'vendor_react',
|
|
|
|
filename: 'vendor.react.js',
|
|
|
|
chunks: 'all',
|
|
|
|
reuseExistingChunk: true,
|
|
|
|
priority: 8,
|
|
|
|
minChunks: 2,
|
|
|
|
enforce: true,
|
|
|
|
test(module) {
|
|
|
|
return webpackShimConfig.matchModules(module, ['react', 'react-dom']);
|
|
|
|
},
|
|
|
|
},
|
2019-10-10 01:35:28 -05:00
|
|
|
vendor_main: {
|
|
|
|
name: 'vendor_main',
|
|
|
|
filename: 'vendor.main.js',
|
|
|
|
chunks: 'all',
|
|
|
|
reuseExistingChunk: true,
|
|
|
|
priority: 7,
|
|
|
|
minChunks: 2,
|
|
|
|
enforce: true,
|
|
|
|
test(module) {
|
2023-10-27 05:21:45 -05:00
|
|
|
return webpackShimConfig.matchModules(module, ['codemirror', 'rc-', '@material-ui']);
|
2019-10-10 01:35:28 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
vendor_others: {
|
|
|
|
name: 'vendor_others',
|
|
|
|
filename: 'vendor.others.js',
|
|
|
|
chunks: 'all',
|
|
|
|
reuseExistingChunk: true,
|
|
|
|
priority: 6,
|
2019-03-14 10:11:16 -05:00
|
|
|
minChunks: 2,
|
|
|
|
enforce: true,
|
|
|
|
test(module) {
|
|
|
|
return webpackShimConfig.isExternal(module);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
secondary: {
|
|
|
|
name: 'pgadmin_commons',
|
|
|
|
filename: 'pgadmin_commons.js',
|
|
|
|
chunks: 'all',
|
2019-10-10 01:35:28 -05:00
|
|
|
priority: 5,
|
2019-03-14 10:11:16 -05:00
|
|
|
minChunks: 2,
|
|
|
|
enforce: true,
|
|
|
|
test(module) {
|
|
|
|
return webpackShimConfig.isPgAdminLib(module);
|
|
|
|
},
|
|
|
|
},
|
2019-10-10 01:35:28 -05:00
|
|
|
browser_nodes: {
|
|
|
|
name: 'browser_nodes',
|
|
|
|
filename: 'browser_nodes.js',
|
|
|
|
chunks: 'all',
|
|
|
|
priority: 4,
|
|
|
|
minChunks: 2,
|
|
|
|
enforce: true,
|
|
|
|
test(module) {
|
|
|
|
return webpackShimConfig.isBrowserNode(module);
|
|
|
|
},
|
|
|
|
},
|
2019-03-14 10:11:16 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-07-20 06:52:15 -05:00
|
|
|
// Define list of Plugins used in Production or development mode
|
|
|
|
// Ref:https://webpack.js.org/concepts/plugins/#components/sidebar/sidebar.jsx
|
2017-07-18 09:13:16 -05:00
|
|
|
plugins: PRODUCTION ? [
|
2017-07-20 06:52:15 -05:00
|
|
|
extractStyle,
|
2017-07-18 09:13:16 -05:00
|
|
|
providePlugin,
|
2017-09-13 03:47:01 -05:00
|
|
|
sourceMapDevToolPlugin,
|
2019-10-10 01:35:28 -05:00
|
|
|
bundleAnalyzer,
|
2019-11-07 07:21:03 -06:00
|
|
|
copyFiles,
|
2017-07-18 09:13:16 -05:00
|
|
|
]: [
|
2017-07-20 06:52:15 -05:00
|
|
|
extractStyle,
|
2017-07-18 09:13:16 -05:00
|
|
|
providePlugin,
|
2017-08-09 06:00:30 -05:00
|
|
|
sourceMapDevToolPlugin,
|
2019-11-07 07:21:03 -06:00
|
|
|
copyFiles,
|
2017-07-18 09:13:16 -05:00
|
|
|
],
|
2019-11-07 07:21:03 -06:00
|
|
|
}].concat(pgadminThemesWebpack);
|