Translated using Weblate (Russian)
[phpmyadmin.git] / webpack.config.cjs
blob337dccb518d45e475c64826a1ac06c0304422fee
1 const path = require('path');
2 const webpack = require('webpack');
3 const autoprefixer = require('autoprefixer');
4 const CopyPlugin = require('copy-webpack-plugin');
5 const WebpackConcatPlugin = require('webpack-concat-files-plugin');
6 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7 const RtlCssPlugin = require('rtlcss-webpack-plugin');
9 const rootPath = path.resolve(__dirname, '');
10 const publicPath = path.resolve(__dirname, 'public');
12 const typeScriptErrorsToIgnore = [
13     5096, // TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.
16 module.exports = [
17     {
18         mode: 'none',
19         devtool: 'source-map',
20         entry: {
21             'chart': rootPath + '/resources/js/src/chart.ts',
22             'codemirror/addon/lint/sql-lint': rootPath + '/resources/js/src/codemirror/addon/lint/sql-lint.ts',
23             'console': { import: rootPath + '/resources/js/src/console.ts', library: { name: 'Console', type: 'window', export: 'Console' } },
24             'datetimepicker': rootPath + '/resources/js/src/datetimepicker.ts',
25             'database/central_columns': rootPath + '/resources/js/src/database/central_columns.ts',
26             'database/events': rootPath + '/resources/js/src/database/events.ts',
27             'database/multi_table_query': rootPath + '/resources/js/src/database/multi_table_query.ts',
28             'database/operations': rootPath + '/resources/js/src/database/operations.ts',
29             'database/query_generator': rootPath + '/resources/js/src/database/query_generator.ts',
30             'database/routines': rootPath + '/resources/js/src/database/routines.ts',
31             'database/search': rootPath + '/resources/js/src/database/search.ts',
32             'database/structure': rootPath + '/resources/js/src/database/structure.ts',
33             'database/tracking': rootPath + '/resources/js/src/database/tracking.ts',
34             'designer/init': rootPath + '/resources/js/src/designer/init.ts',
35             'drag_drop_import': rootPath + '/resources/js/src/drag_drop_import.ts',
36             'error_report': rootPath + '/resources/js/src/error_report.ts',
37             'export': rootPath + '/resources/js/src/export.ts',
38             'export_output': rootPath + '/resources/js/src/export_output.ts',
39             'gis_data_editor': rootPath + '/resources/js/src/gis_data_editor.ts',
40             'home': rootPath + '/resources/js/src/home.ts',
41             'import': rootPath + '/resources/js/src/import.ts',
42             'jqplot/plugins/jqplot.byteFormatter': rootPath + '/resources/js/src/jqplot/plugins/jqplot.byteFormatter.ts',
43             'jquery.sortable-table': rootPath + '/resources/js/src/jquery.sortable-table.ts',
44             'main': rootPath + '/resources/js/src/main.ts',
45             'makegrid': rootPath + '/resources/js/src/makegrid.ts',
46             'menu_resizer': rootPath + '/resources/js/src/menu_resizer.ts',
47             'multi_column_sort': rootPath + '/resources/js/src/multi_column_sort.ts',
48             'name-conflict-fixes': rootPath + '/resources/js/src/name-conflict-fixes.ts',
49             'normalization': rootPath + '/resources/js/src/normalization.ts',
50             'replication': rootPath + '/resources/js/src/replication.ts',
51             'server/databases': rootPath + '/resources/js/src/server/databases.ts',
52             'server/plugins': rootPath + '/resources/js/src/server/plugins.ts',
53             'server/privileges': rootPath + '/resources/js/src/server/privileges.ts',
54             'server/status/monitor': rootPath + '/resources/js/src/server/status/monitor.ts',
55             'server/status/processes': rootPath + '/resources/js/src/server/status/processes.ts',
56             'server/status/queries': rootPath + '/resources/js/src/server/status/queries.ts',
57             'server/status/variables': rootPath + '/resources/js/src/server/status/variables.ts',
58             'server/user_groups': rootPath + '/resources/js/src/server/user_groups.ts',
59             'server/variables': rootPath + '/resources/js/src/server/variables.ts',
60             'setup/scripts': rootPath + '/resources/js/src/setup/scripts.ts',
61             'shortcuts_handler': rootPath + '/resources/js/src/shortcuts_handler.ts',
62             'sql': rootPath + '/resources/js/src/sql.ts',
63             'table/change': rootPath + '/resources/js/src/table/change.ts',
64             'table/chart': rootPath + '/resources/js/src/table/chart.ts',
65             'table/find_replace': rootPath + '/resources/js/src/table/find_replace.ts',
66             'table/gis_visualization': rootPath + '/resources/js/src/table/gis_visualization.ts',
67             'table/operations': rootPath + '/resources/js/src/table/operations.ts',
68             'table/relation': rootPath + '/resources/js/src/table/relation.ts',
69             'table/select': rootPath + '/resources/js/src/table/select.ts',
70             'table/structure': rootPath + '/resources/js/src/table/structure.ts',
71             'table/tracking': rootPath + '/resources/js/src/table/tracking.ts',
72             'table/zoom_plot_jqplot': rootPath + '/resources/js/src/table/zoom_plot_jqplot.ts',
73             'transformations/image_upload': rootPath + '/resources/js/src/transformations/image_upload.ts',
74             'transformations/json': rootPath + '/resources/js/src/transformations/json.ts',
75             'transformations/json_editor': rootPath + '/resources/js/src/transformations/json_editor.ts',
76             'transformations/sql_editor': rootPath + '/resources/js/src/transformations/sql_editor.ts',
77             'transformations/xml': rootPath + '/resources/js/src/transformations/xml.ts',
78             'transformations/xml_editor': rootPath + '/resources/js/src/transformations/xml_editor.ts',
79             'triggers': rootPath + '/resources/js/src/triggers.ts',
80             'u2f': rootPath + '/resources/js/src/u2f.ts',
81             'validator-messages': rootPath + '/resources/js/src/validator-messages.ts',
82             'webauthn': rootPath + '/resources/js/src/webauthn.ts',
83         },
84         output: {
85             filename: '[name].js',
86             path: publicPath + '/js/dist',
87         },
88         optimization: {
89             runtimeChunk: 'single',
90             splitChunks: {
91                 chunks: 'all',
92                 name: 'shared',
93                 minSize: 1,
94             },
95         },
96         externals: {
97             jquery: 'jQuery',
98             codemirror: 'CodeMirror',
99         },
100         module: {
101             rules: [
102                 {
103                     test: /\.ts$/,
104                     exclude: /node_modules/,
105                     use: [
106                         { loader: 'babel-loader', options: { presets:  ['@babel/preset-env'] } },
107                         { loader: 'ts-loader', options: { ignoreDiagnostics: typeScriptErrorsToIgnore } },
108                     ],
109                 },
110                 {
111                     test: /\.js$/,
112                     exclude: /node_modules/,
113                     use: { loader: 'babel-loader', options: { presets:  ['@babel/preset-env'] } },
114                 },
115             ],
116         },
117         plugins: [
118             new CopyPlugin({
119                 patterns: [
120                     { from: rootPath + '/node_modules/codemirror/addon/hint/sql-hint.js', to: publicPath + '/js/vendor/codemirror/addon/hint/sql-hint.js' },
121                     { from: rootPath + '/node_modules/codemirror/addon/hint/show-hint.css', to: publicPath + '/js/vendor/codemirror/addon/hint/show-hint.css' },
122                     { from: rootPath + '/node_modules/codemirror/addon/hint/show-hint.js', to: publicPath + '/js/vendor/codemirror/addon/hint/show-hint.js' },
123                     { from: rootPath + '/node_modules/codemirror/addon/runmode/runmode.js', to: publicPath + '/js/vendor/codemirror/addon/runmode/runmode.js' },
124                     { from: rootPath + '/node_modules/codemirror/addon/lint/lint.css', to: publicPath + '/js/vendor/codemirror/addon/lint/lint.css' },
125                     { from: rootPath + '/node_modules/codemirror/addon/lint/lint.js', to: publicPath + '/js/vendor/codemirror/addon/lint/lint.js' },
126                     { from: rootPath + '/node_modules/codemirror/lib/codemirror.js', to: publicPath + '/js/vendor/codemirror/lib/codemirror.js' },
127                     { from: rootPath + '/node_modules/codemirror/lib/codemirror.css', to: publicPath + '/js/vendor/codemirror/lib/codemirror.css' },
128                     { from: rootPath + '/node_modules/codemirror/mode/sql/sql.js', to: publicPath + '/js/vendor/codemirror/mode/sql/sql.js' },
129                     { from: rootPath + '/node_modules/codemirror/mode/javascript/javascript.js', to: publicPath + '/js/vendor/codemirror/mode/javascript/javascript.js' },
130                     { from: rootPath + '/node_modules/codemirror/mode/xml/xml.js', to: publicPath + '/js/vendor/codemirror/mode/xml/xml.js' },
131                     { from: rootPath + '/node_modules/codemirror/LICENSE', to: publicPath + '/js/vendor/codemirror/LICENSE', toType: 'file' },
132                     { from: rootPath + '/node_modules/jquery/dist/jquery.min.js', to: publicPath + '/js/vendor/jquery/jquery.min.js' },
133                     { from: rootPath + '/node_modules/jquery/dist/jquery.min.map', to: publicPath + '/js/vendor/jquery/jquery.min.map' },
134                     { from: rootPath + '/node_modules/jquery/LICENSE.txt', to: publicPath + '/js/vendor/jquery/MIT-LICENSE.txt' },
135                     { from: rootPath + '/node_modules/jquery-migrate/dist/jquery-migrate.min.js', to: publicPath + '/js/vendor/jquery/jquery-migrate.min.js' },
136                     { from: rootPath + '/node_modules/jquery-migrate/dist/jquery-migrate.min.map', to: publicPath + '/js/vendor/jquery/jquery-migrate.min.map' },
137                     { from: rootPath + '/node_modules/jquery-ui-dist/jquery-ui.min.js', to: publicPath + '/js/vendor/jquery/jquery-ui.min.js' },
138                     { from: rootPath + '/node_modules/jquery-validation/dist/jquery.validate.min.js', to: publicPath + '/js/vendor/jquery/jquery.validate.min.js' },
139                     { from: rootPath + '/node_modules/jquery-validation/dist/additional-methods.js', to: publicPath + '/js/vendor/jquery/additional-methods.js' },
140                     { from: rootPath + '/node_modules/js-cookie/dist/js.cookie.min.js', to: publicPath + '/js/vendor/js.cookie.min.js' },
141                     { from: rootPath + '/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js', to: publicPath + '/js/vendor/bootstrap/bootstrap.bundle.min.js' },
142                     { from: rootPath + '/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map', to: publicPath + '/js/vendor/bootstrap/bootstrap.bundle.min.js.map' },
143                     { from: rootPath + '/node_modules/@zxcvbn-ts/core/dist/zxcvbn-ts.js', to: publicPath + '/js/vendor/zxcvbn-ts.js' },
144                     { from: rootPath + '/node_modules/@zxcvbn-ts/core/dist/zxcvbn-ts.js.map', to: publicPath + '/js/vendor/zxcvbn-ts.js.map' },
145                     { from: rootPath + '/node_modules/tracekit/tracekit.js', to: publicPath + '/js/vendor/tracekit.js' },
146                     { from: rootPath + '/node_modules/u2f-api-polyfill/u2f-api-polyfill.js', to: publicPath + '/js/vendor/u2f-api-polyfill.js' },
147                     { from: rootPath + '/node_modules/jquery-uitablefilter/jquery.uitablefilter.js', to: publicPath + '/js/vendor/jquery/jquery.uitablefilter.js' },
148                     { from: rootPath + '/node_modules/tablesorter/dist/js/jquery.tablesorter.js', to: publicPath + '/js/vendor/jquery/jquery.tablesorter.js' },
149                     { from: rootPath + '/node_modules/jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.js', to: publicPath + '/js/vendor/jquery/jquery-ui-timepicker-addon.js' },
150                     { from: rootPath + '/node_modules/ol/ol.css', to: publicPath + '/js/vendor/openlayers/theme/ol.css' },
151                     { from: rootPath + '/node_modules/locutus.sprintf/src/php/strings/sprintf.browser.js', to: publicPath + '/js/vendor/sprintf.js' },
152                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.pieRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.pieRenderer.js' },
153                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.barRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.barRenderer.js' },
154                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.pointLabels.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.pointLabels.js' },
155                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.enhancedPieLegendRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.enhancedPieLegendRenderer.js' },
156                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.dateAxisRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.dateAxisRenderer.js' },
157                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.categoryAxisRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.categoryAxisRenderer.js' },
158                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.canvasTextRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.canvasTextRenderer.js' },
159                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.canvasAxisLabelRenderer.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js' },
160                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.cursor.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.cursor.js' },
161                     { from: rootPath + '/node_modules/updated-jqplot/build/plugins/jqplot.highlighter.js', to: publicPath + '/js/vendor/jqplot/plugins/jqplot.highlighter.js' },
162                     { from: rootPath + '/node_modules/chart.js/dist/chart.umd.js', to: publicPath + '/js/vendor/chart.umd.js' },
163                     { from: rootPath + '/node_modules/chart.js/dist/chart.umd.js.map', to: publicPath + '/js/vendor/chart.umd.js.map' },
164                 ],
165             }),
166             new WebpackConcatPlugin({
167                 bundles: [
168                     {
169                         dest: publicPath + '/js/vendor/jqplot/jquery.jqplot.js',
170                         src: [
171                             rootPath + '/node_modules/updated-jqplot/build/jqplot.core.js',
172                             rootPath + '/node_modules/updated-jqplot/build/jqplot.axisLabelRenderer.js',
173                             rootPath + '/node_modules/updated-jqplot/build/jqplot.axisTickRenderer.js',
174                             rootPath + '/node_modules/updated-jqplot/build/jqplot.canvasGridRenderer.js',
175                             rootPath + '/node_modules/updated-jqplot/build/jqplot.divTitleRenderer.js',
176                             rootPath + '/node_modules/updated-jqplot/build/jqplot.linePattern.js',
177                             rootPath + '/node_modules/updated-jqplot/build/jqplot.lineRenderer.js',
178                             rootPath + '/node_modules/updated-jqplot/build/jqplot.linearAxisRenderer.js',
179                             rootPath + '/node_modules/updated-jqplot/build/jqplot.linearTickGenerator.js',
180                             rootPath + '/node_modules/updated-jqplot/build/jqplot.markerRenderer.js',
181                             rootPath + '/node_modules/updated-jqplot/build/jqplot.shadowRenderer.js',
182                             rootPath + '/node_modules/updated-jqplot/build/jqplot.shapeRenderer.js',
183                             rootPath + '/node_modules/updated-jqplot/build/jqplot.tableLegendRenderer.js',
184                             rootPath + '/node_modules/updated-jqplot/build/jqplot.themeEngine.js',
185                             rootPath + '/node_modules/updated-jqplot/build/jqplot.toImage.js',
186                             rootPath + '/node_modules/updated-jqplot/build/jsdate.js',
187                             rootPath + '/node_modules/updated-jqplot/build/jqplot.sprintf.js',
188                             rootPath + '/node_modules/updated-jqplot/build/jqplot.effects.core.js',
189                             rootPath + '/node_modules/updated-jqplot/build/jqplot.effects.blind.js',
190                         ],
191                     },
192                 ],
193             }),
194         ],
195     },
196     {
197         name: 'OpenLayers',
198         entry: rootPath + '/resources/js/src/ol.mjs',
199         devtool: 'source-map',
200         mode: 'production',
201         performance: {
202             hints: false,
203             maxEntrypointSize: 512000,
204             maxAssetSize: 512000,
205         },
206         output: {
207             path: publicPath + '/js/vendor/openlayers',
208             filename: 'OpenLayers.js',
209             library: 'ol',
210             libraryTarget: 'umd',
211             libraryExport: 'default',
212         },
213         plugins: [
214             new webpack.BannerPlugin({
215                 banner: 'OpenLayers (https://openlayers.org/)\nCopyright 2005-present, OpenLayers Contributors All rights reserved.\nLicensed under BSD 2-Clause License (https://github.com/openlayers/openlayers/blob/main/LICENSE.md)',
216             }),
217         ],
218         optimization: {
219             minimize: false,
220         }
221     },
222     {
223         name: 'CSS',
224         mode: 'none',
225         devtool: 'source-map',
226         entry: {
227             'themes/bootstrap/css/theme': publicPath + '/themes/bootstrap/scss/theme.scss',
228             'themes/metro/css/theme': publicPath + '/themes/metro/scss/theme.scss',
229             'themes/original/css/theme': publicPath + '/themes/original/scss/theme.scss',
230             'themes/pmahomme/css/theme': publicPath + '/themes/pmahomme/scss/theme.scss',
231             'setup/styles': publicPath + '/setup/scss/styles.scss',
232         },
233         output: {
234             filename: 'build/css/[name].js',
235             path: publicPath,
236         },
237         module: {
238             rules: [
239                 {
240                     test: /\.scss$/,
241                     use: [
242                         MiniCssExtractPlugin.loader,
243                         {
244                             loader: 'css-loader',
245                             options: {
246                                 url: false,
247                             },
248                         },
249                         {
250                             loader: 'postcss-loader',
251                             options: {
252                                 postcssOptions: {
253                                     plugins: [ autoprefixer() ],
254                                 },
255                             },
256                         },
257                         'sass-loader',
258                     ],
259                 },
260             ],
261         },
262         plugins: [
263             new MiniCssExtractPlugin({
264                 filename: '[name].css',
265                 chunkFilename: '[id].css',
266             }),
267             new RtlCssPlugin({
268                 filename: '[name].rtl.css',
269             }),
270         ],
271     },