You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/configuration/configuration-languages.mdx
+33-45Lines changed: 33 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,23 @@
1
1
---
2
-
title: Configuration Languages
2
+
title: لغات التخصيص
3
3
sort: 2
4
4
contributors:
5
-
- piouson
6
-
- sokra
7
-
- skipjack
8
-
- tarang9211
9
-
- simon04
10
-
- peterblazejewicz
11
-
- youta1119
12
-
- byzyk
13
-
- Nek-
14
-
- liyiming22
15
-
- daimalou
16
-
- ChocolateLoverRaj
17
-
- snitin315
5
+
- RlxChap2
18
6
---
19
7
20
-
Webpack accepts configuration files written in multiple programming and data languages. The list of supported file extensions can be found in the [node-interpret](https://github.com/gulpjs/interpret) package. Using[node-interpret](https://github.com/gulpjs/interpret), webpack can handle many different types of configuration files.
8
+
يقبل webpack ملفات تخصيص مكتوبة بعدّة لغات برمجة ولغات بيانات. تجد قائمة بامتدادات الملفات المدعومة في حزمة [node-interpret](https://github.com/gulpjs/interpret). فعبر[node-interpret](https://github.com/gulpjs/interpret)، يستطيع webpack التعامل مع أنواع كثيرة ومختلفة من ملفات التخصيص.
21
9
22
10
## TypeScript
23
11
24
-
To write the webpack configuration in [TypeScript](http://www.typescriptlang.org/), you would first install the necessary dependencies, i.e., TypeScript and the relevant type definitions from the [DefinitelyTyped](https://definitelytyped.org/) project:
12
+
لكتابة تخصيص webpack بلغة [TypeScript](http://www.typescriptlang.org/)، ثبّت أوّلاً الاعتماديات اللازمة، وهي TypeScript وتعريفات الأنواع ذات الصلة من مشروع [DefinitelyTyped](https://definitelytyped.org/):
#وإن كنت تستخدم webpack-dev-server بإصدار أقل من v4.7.0
29
17
npm install --save-dev @types/webpack-dev-server
30
18
```
31
19
32
-
and then proceed to write your configuration:
20
+
ثم ابدأ بكتابة التخصيص:
33
21
34
22
**webpack.config.ts**
35
23
@@ -38,7 +26,7 @@ import path from "node:path";
38
26
import { fileURLToPath } from"node:url";
39
27
40
28
importwebpackfrom"webpack";
41
-
//in case you run into any typescript error when configuring `devServer`
29
+
//في حال واجهتك أخطاء TypeScript عند تخصيص `devServer`
42
30
import"webpack-dev-server";
43
31
44
32
const __filename =fileURLToPath(import.meta.url);
@@ -69,31 +57,31 @@ export default config;
69
57
"resolveJsonModule": true,
70
58
"isolatedModules": true,
71
59
72
-
// Allows you to write `import ... from './file.ts';`
60
+
// يتيح لك كتابة `import ... from './file.ts';`
73
61
"rewriteRelativeImportExtensions": true
74
62
}
75
63
}
76
64
```
77
65
78
-
The above sample assumes version >= 2.7 or newer of TypeScript is used with the new `esModuleInterop`and`allowSyntheticDefaultImports`compiler options in your `tsconfig.json` file.
66
+
يفترض المثال السابق أنّك تستخدم إصدار TypeScript رقم 2.7 أو أحدث، مع تفعيل خياري `esModuleInterop`و`allowSyntheticDefaultImports`في ملف `tsconfig.json`.
79
67
80
-
We support configuration in both `CommonJS`and`ESM`format.
68
+
ندعم التخصيص بصيغة `CommonJS`و`ESM`معاً.
81
69
82
-
Starting with v22.18.0Node.js supports built-in [type stripping](https://nodejs.org/api/typescript.html#type-stripping), so the additional settings described below are only required for older versions.
70
+
بدءاً من الإصدار v22.18.0، أصبح Node.js يدعم [إزالة الأنواع (type stripping)](https://nodejs.org/api/typescript.html#type-stripping) بشكل أصلي، ولذلك فإنّ الإعدادات الإضافية الموضّحة أدناه ليست مطلوبة إلا للإصدارات الأقدم.
83
71
84
-
> To enable the transformation of non erasable TypeScript syntax, which requires JavaScript code generation, such as enum declarations, parameter properties use the flag[--experimental-transform-types](https://nodejs.org/api/cli.html#experimental-transform-types).
72
+
> لتفعيل تحويل صياغات TypeScript غير القابلة للحذف، التي تحتاج إلى توليد شيفرة JavaScript مثل تصريحات `enum` وخصائص المُعاملات (parameter properties)، استخدم الراية[--experimental-transform-types](https://nodejs.org/api/cli.html#experimental-transform-types).
85
73
86
-
If you are using an older version of Node.js that does not support the `typescript` format, or want to set `module`in`compilerOptions`in`tsconfig.json`to`commonjs` there are three solutions to this issue:
74
+
إذا كنت تستخدم إصداراً أقدم من Node.js لا يدعم صيغة `typescript`، أو أردت ضبط `module`في`compilerOptions`ضمن`tsconfig.json`على`commonjs`، فأمامك ثلاثة حلول لهذه المشكلة:
-تعديل`tsconfig.json`وإضافة إعدادات خاصة بـ`ts-node`.
78
+
-تثبيت`tsconfig-paths`.
91
79
92
-
The **first option** is to open your `tsconfig.json`file and look for `compilerOptions`. Set `target`to`"ES5"`and`module`to`"CommonJS"` (or completely remove the `module`option).
80
+
**الحلّ الأول**: افتح ملف `tsconfig.json`وابحث عن `compilerOptions`، ثم اضبط `target`على`"ES5"`و`module`على`"CommonJS"` (أو احذف خيار `module`تماماً).
93
81
94
-
The **second option** is to add settings for ts-node:
82
+
**الحلّ الثاني**: أضِف إعدادات خاصة بـ ts-node.
95
83
96
-
You can keep `"module": "ESNext"`for`tsc`, and if you use webpack, or another build tool, set an override for ts-node. [ts-node config](https://typestrong.org/ts-node/docs/imports/)
84
+
يمكنك إبقاء `"module": "ESNext"`لـ`tsc`، وإن كنت تستعمل webpack أو أداة بناء أخرى، فاضبط قيمة بديلة لـ ts-node. [توثيق إعداد ts-node](https://typestrong.org/ts-node/docs/imports/)
97
85
98
86
```json
99
87
{
@@ -108,13 +96,13 @@ You can keep `"module": "ESNext"` for `tsc`, and if you use webpack, or another
108
96
}
109
97
```
110
98
111
-
The **third option** is to install the `tsconfig-paths` package:
99
+
**الحلّ الثالث**: ثبّت حزمة `tsconfig-paths`:
112
100
113
101
```bash
114
102
npm install --save-dev tsconfig-paths
115
103
```
116
104
117
-
And create a separate TypeScript configuration specifically for your webpack configs:
105
+
ثم أنشئ تخصيصاً مستقلاً لـ TypeScript مخصّصاً لملفات تخصيص webpack:
118
106
119
107
**tsconfig-for-webpack-config.json**
120
108
@@ -128,9 +116,9 @@ And create a separate TypeScript configuration specifically for your webpack con
128
116
}
129
117
```
130
118
131
-
T> `ts-node`can resolve a `tsconfig.json`file using the environment variable provided by`tsconfig-paths`.
119
+
T> يستطيع `ts-node`تحديد ملف `tsconfig.json`المطلوب عبر متغيّر البيئة الذي توفّره`tsconfig-paths`.
132
120
133
-
Then set the environment variable `process.env.TS_NODE_PROJECT`provided by`tsconfig-paths`like so:
121
+
ثم اضبط متغيّر البيئة `process.env.TS_NODE_PROJECT`الذي توفّره`tsconfig-paths`على النحو التالي:
134
122
135
123
**package.json**
136
124
@@ -142,17 +130,17 @@ Then set the environment variable `process.env.TS_NODE_PROJECT` provided by `tsc
142
130
}
143
131
```
144
132
145
-
W> We had been getting reports that `TS_NODE_PROJECT`might not work with `"TS_NODE_PROJECT" unrecognized command` error. Therefore running it with `cross-env`seems to fix the issue, for more info [see this issue](https://github.com/webpack/webpack.js.org/issues/2733).
133
+
W> وردتنا بلاغات بأن `TS_NODE_PROJECT`قد لا يعمل أحياناً ويُظهر الخطأ `"TS_NODE_PROJECT" unrecognized command`. وقد ظهر أنّ تشغيله عبر `cross-env`يحلّ المشكلة. لمزيد من التفاصيل [راجع هذه القضية](https://github.com/webpack/webpack.js.org/issues/2733).
146
134
147
-
## CoffeeScript
135
+
## كوفي سكريبت
148
136
149
-
Similarly, to use[CoffeeScript](https://coffeescript.org/), you would first install the necessary dependencies:
W> If you are using Babel elsewhere and have `modules`set to `false`, you will have to either maintain two separate `.babelrc`files or use`const jsxobj = require('jsxobj');`and`module.exports`instead of the new `import`and`export`syntax. This is because while Node does support many new ES6 features, they don't yet support ES6 module syntax.
227
+
W> إن كنت تستخدم Babel في أماكن أخرى وضبطت `modules`على `false`، فستضطر إمّا للاحتفاظ بملفَّي `.babelrc`منفصلين، أو استخدام`const jsxobj = require('jsxobj');`و`module.exports`بدلاً من صياغة `import`و`export`الجديدة. ذلك أنّ Node يدعم كثيراً من ميزات ES6 الجديدة، لكنه لا يدعم بعدُ صياغة وحدات ES6.
Copy file name to clipboardExpand all lines: src/content/configuration/configuration-types.mdx
+22-34Lines changed: 22 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,18 @@
1
1
---
2
-
title: Configuration Types
2
+
title: أنواع التخصيص
3
3
sort: 3
4
4
contributors:
5
-
- sokra
6
-
- skipjack
7
-
- kbariotis
8
-
- simon04
9
-
- fadysamirsadek
10
-
- byzyk
11
-
- EugeneHlushko
12
-
- dhurlburtusa
13
-
- anshumanv
14
-
- thorn0
15
-
- tusharthakur04
5
+
- RlxChap2
16
6
---
17
7
18
-
Besides exporting a single configuration object, there are a few more ways that cover other needs as well.
8
+
إلى جانب تصدير كائن تخصيص واحد، هناك طرق أخرى تغطّي احتياجات مختلفة.
19
9
20
-
## Exporting a Function
10
+
## تصدير دالّة
21
11
22
-
Eventually you will find the need to disambiguate in your `webpack.config.js`between [development](/guides/development)and [production builds](/guides/production). There are multiple ways to do that. One option is to export a function from your webpack configuration instead of exporting an object. The function will be invoked with two arguments:
12
+
ستجد عاجلاً أم آجلاً حاجة إلى التمييز داخل `webpack.config.js`بين [بناء التطوير](/guides/development)و[بناء الإنتاج](/guides/production). وثمّة طرق متعددة لذلك. من بينها أن تُصدّر دالّة من ملف تخصيص webpack بدلاً من تصدير كائن. سيتمّ استدعاء هذه الدالّة بمعاملين:
23
13
24
-
-An environment as the first parameter. See the [environment options CLI documentation](/api/cli/#environment-options)for syntax examples.
25
-
-An options map (`argv`) as the second parameter. This describes the options passed to webpack, with keys such as [`output-path`](/api/cli/#flags)and [`mode`](/api/cli/#flags).
14
+
-بيئة (environment) بوصفها المعامل الأول. راجع [توثيق خيارات البيئة في الـ CLI](/api/cli/#environment-options)لأمثلة على الصياغة.
15
+
-خريطة خيارات (`argv`) بوصفها المعامل الثاني. تصف هذه الخريطة الخيارات الممرَّرة إلى webpack، بمفاتيح مثل [`output-path`](/api/cli/#flags)و[`mode`](/api/cli/#flags).
26
16
27
17
```diff
28
18
-export default {
@@ -33,19 +23,19 @@ Eventually you will find the need to disambiguate in your `webpack.config.js` be
33
23
plugins: [
34
24
new MinimizerPlugin({
35
25
minimizerOptions: {
36
-
+ compress: argv.mode === 'production' // only if `--mode production` was passed
26
+
+ compress: argv.mode === 'production' // فقط في حال تمرير `--mode production`
37
27
}
38
28
})
39
29
]
40
30
+ };
41
31
};
42
32
```
43
33
44
-
## Exporting a Promise
34
+
## تصدير Promise
45
35
46
-
Webpack will run the function exported by the configuration file and wait for a Promise to be returned. Handy when you need to asynchronously load configuration variables.
36
+
سيُشغّل webpack الدالّة المُصدَّرة من ملف التخصيص، وينتظر منها إرجاع Promise. وهذا مفيد حين تحتاج إلى تحميل متغيّرات التخصيص بشكل غير متزامن.
47
37
48
-
T> It is possible to export multiple promises by wrapping them into `Promise.all([/* Your promises */]).`
38
+
T> يمكنك تصدير عدّة Promises عبر تغليفها داخل `Promise.all([/* Promises الخاصة بك */])`.
49
39
50
40
```js
51
41
exportdefault () =>
@@ -59,11 +49,11 @@ export default () =>
59
49
});
60
50
```
61
51
62
-
W> Returning a `Promise`only works when using webpack via CLI. [`webpack()`](/api/node/#webpack)expects an object.
52
+
W> إرجاع `Promise`يعمل فقط حين تستخدم webpack عبر الـ CLI. أمّا [`webpack()`](/api/node/#webpack)فيتوقّع كائناً.
63
53
64
-
## Exporting multiple configurations
54
+
## تصدير تخصيصات متعددة
65
55
66
-
Instead of exporting a single configuration object/function, you may export multiple configurations (multiple functions are supported since webpack 3.1.0). When running webpack, all configurations are built. For instance, this is useful for [bundling a library](/guides/author-libraries)for multiple [targets](/configuration/output/#outputlibrarytarget)such as AMD and CommonJS:
56
+
عوضاً عن تصدير كائن أو دالّة تخصيص واحدة، يمكنك تصدير عدّة تخصيصات (وقد دُعمت الدوال المتعددة منذ webpack 3.1.0). وعند تشغيل webpack، تُبنى كل التخصيصات معاً. وهذا مفيد مثلاً عند [حزم مكتبة](/guides/author-libraries)لعدّة [أهداف (targets)](/configuration/output/#outputlibrarytarget)كـ AMD و CommonJS:
67
57
68
58
```js
69
59
exportdefault [
@@ -88,11 +78,11 @@ export default [
88
78
];
89
79
```
90
80
91
-
T> If you pass a name to [`--config-name`](/api/cli/#config-name) flag, webpack will only build that specific configuration.
81
+
T> لو مرّرت اسماً إلى الراية [`--config-name`](/api/cli/#config-name)، فلن يبني webpack إلا التخصيص المطابق لذلك الاسم فقط.
92
82
93
83
### dependencies
94
84
95
-
In case you have a configuration that depends on the output of another configuration, you can specify a list of dependencies using the [`dependencies`](/configuration/other-options/#dependencies) array.
85
+
إن كان لديك تخصيص يعتمد على ناتج تخصيص آخر، فيمكنك تحديد قائمة بالاعتماديات عبر مصفوفة [`dependencies`](/configuration/other-options/#dependencies).
96
86
97
87
**webpack.config.js**
98
88
@@ -111,26 +101,24 @@ export default [
111
101
];
112
102
```
113
103
114
-
### parallelism
104
+
### التوازي
115
105
116
-
In case you export multiple configurations, you can use the `parallelism`option on the configuration array to specify the maximum number of compilers that will compile in parallel.
106
+
عند تصدير تخصيصات متعددة، يمكنك استخدام الخيار `parallelism`على مصفوفة التخصيصات لتحديد الحدّ الأقصى لعدد الـ compilers التي ستعمل بالتوازي.
0 commit comments