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