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