UNPKG

4.5 kBMarkdownView Raw
1CKEditor 5 webpack plugin
2=========================
3
4[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-dev-webpack-plugin.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-webpack-plugin)
5[![Build Status](https://travis-ci.com/ckeditor/ckeditor5-dev.svg?branch=master)](https://app.travis-ci.com/github/ckeditor/ckeditor5-dev)
6![Dependency Status](https://img.shields.io/librariesio/release/npm/@ckeditor/ckeditor5-dev-webpack-plugin)
7
8Intergrate [CKEditor 5](https://ckeditor.com)'s build process with your [webpack](https://webpack.js.org) setup.
9
10Requires webpack `^4.0.0` or `^5.0.0`.
11
12More information about development tools packages can be found at the following URL: <https://github.com/ckeditor/ckeditor5-dev>.
13
14## Usage
15
16The current functionality of this plugin is limited to localizing the editor builds. Add this plugin to your webpack configuration to change the language of the editor's interface or build the editor with support for multiple languages (by extracting multiple language files):
17
18```js
19const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
20
21// Define webpack plugins ...
22 plugins: [
23 new CKEditorWebpackPlugin( options ),
24
25 // Other webpack plugins...
26 ]
27// ...
28```
29
30### Options:
31
32#### `language`
33
34The main language that will be built into the main bundle, e.g. `en`.
35
36#### `additionalLanguages`
37
38Additional languages that will be emitted to the `outputDirectory`. This option can be set to an array of language codes or `'all'` to build all found languages. The bundle is optimized for one language when this option is omitted.
39
40### `outputDirectory`
41
42An optional directory for emitted translations. Relative to the webpack's output. Defaults to `'translations'`.
43
44### `strict`
45
46When set to `true`, it stops the webpack compilation when an error occurs. Defaults to `false`.
47
48### `verbose`
49
50When set to `true`, it logs all warnings found during the compilation. Defaults to `false`.
51
52### `addMainLanguageTranslationsToAllAssets`
53
54When set to `true`, all generated assets (bundles) will include translations for the main language.
55
56### `buildAllTranslationsToSeparateFiles`
57
58When set to `true`, all translations will be output to the `translations` directory (or the directory specified by the [`outputDirectory` option](#outputDirectory)).
59
60### `packageNamesPattern`
61
62A pattern which is used for determining if a package may contain translations (PO files) in the `<package_name>/lang/translations` directory. Defaults to `/[/\\]ckeditor5-[^/\\]+[/\\]/`.
63
64### `sourceFilesPattern`
65
66A pattern which is used for determining if a file may contain messages to translate. Defaults to `/[/\\]ckeditor5-[^/\\]+[/\\]src[/\\].+\.js$/`.
67
68### `translationsOutputFile`
69
70An option that allows specifying the target file to which all translations will be outputted. This option supports a string, regular expression and a function. If no asset exists with the name, it will be created automatically and filled with translations.
71
72### `includeCorePackageTranslations`
73
74When set to `true`, all translations from the `ckeditor5-core` package will be added into the bundle files. Defaults to `false`.
75
76### `skipPluralFormFunction`
77
78When set to `true`, the `getPluralForm()` function (if exists for the specified language) will not be added into the bundle file. Defaults to `false`.
79
80### `corePackagePattern`
81
82(internal)
83A pattern which is used to get a path to the core translation package from `corePackageSampleResourcePath`, which contains the main translations. Defaults to /[/\\]ckeditor5-core/.
84
85### `corePackageSampleResourcePath`
86
87(internal)
88A sample path to the `ckeditor5-core` package. A test import to this file shows if the `ckeditor5-core` package is available and allows to load the core package translations first.
89
90### `corePackageContextsResourcePath`
91
92(internal)
93A path the `context.json` file in the `ckeditor5-core` package. It is used if the `includeCorePackageTranslations` option is set to `true`.
94
95You can read more about localizing the editor in the [Setting the UI language](https://docs.ckeditor.com/ckeditor5/latest/features/ui-language.html) guide.
96
97## Changelog
98
99See the [`CHANGELOG.md`](https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-webpack-plugin/CHANGELOG.md) file.
100
101## License
102
103Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file.