Skip to content

Commit

Permalink
Aligned legacy webpack configurations to changes in ckeditor5-dev-*.
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Oct 2, 2024
1 parent e21ed5a commit cdbcd7e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 23 deletions.
37 changes: 25 additions & 12 deletions docs/getting-started/advanced/integrating-from-source-webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,17 @@ You can now configure webpack. There are a couple of things that you need to tak
The minimal configuration, assuming that you use the same methods of handling assets as CKEditor 5 builds, will look like this:

```js
// webpack.config.js
import path from 'path';
import { createRequire } from 'module';
import { styles } from '@ckeditor/ckeditor5-dev-utils';
import { CKEditorTranslationsPlugin } from '@ckeditor/ckeditor5-dev-translations';

const path = require( 'path' );
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );

module.exports = {
const require = createRequire( import.meta.url );

export default {
entry: './main.js',
output: {
path: path.resolve( __dirname, 'dist' ),
Expand Down Expand Up @@ -136,13 +140,17 @@ module.exports = {
Optionally, you may need to handle `.ts` files to use TypeScript in your project. There is the [`ts-loader`](https://webpack.js.org/guides/typescript/#loader) for this purpose. Webpack configuration must take into account these changes.
```js
// webpack.config.js
import path from 'path';
import { createRequire } from 'module';
import { styles } from '@ckeditor/ckeditor5-dev-utils';
import { CKEditorTranslationsPlugin } from '@ckeditor/ckeditor5-dev-translations';

const path = require( 'path' );
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );

const require = createRequire( import.meta.url );

module.exports = {
export default {
entry: './main.ts',
output: {
path: path.resolve( __dirname, 'dist' ),
Expand Down Expand Up @@ -568,9 +576,14 @@ npm install --save \
And add it to your webpack configuration:
```js
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );

module.exports = {
import path from 'path';
import { createRequire } from 'module';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';

const require = createRequire( import.meta.url );

export default {
// More configuration.
// ...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ First, import an object that provides a utility for creating the configuration f

```js
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
// or use an `import` instruction when developing an ESM project (`type=module`).
import { styles } from '@ckeditor/ckeditor5-dev-utils';
```

Then, add two new elements to the exported object under the `module.rules` array (as new items of the `oneOf` array). These are SVG and CSS loaders required to handle the CKEditor 5 source:
Expand Down Expand Up @@ -738,6 +740,8 @@ Then, add the installed plugin to the webpack configuration:

// ...
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
// or use an `import` instruction when developing an ESM project (`type=module`).
import { CKEditorTranslationsPlugin } from '@ckeditor/ckeditor5-dev-translations';

module.exports = {
// ...
Expand Down
16 changes: 10 additions & 6 deletions docs/getting-started/legacy-getting-started/quick-start-other.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Then, install the packages needed to build CKEditor 5:

```bash
npm install --save \
@ckeditor/ckeditor5-dev-utils \
css-loader@5 \
postcss-loader@4 \
raw-loader@4 \
Expand All @@ -220,14 +221,18 @@ npm install --save \
The minimal webpack configuration needed to enable building CKEditor 5 is:

```js
// webpack.config.js
// webpack.config.mjs

import path from 'path';
import { createRequire } from 'module';
import { styles } from '@ckeditor/ckeditor5-dev-utils';

'use strict';
const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );

const path = require( 'path' );
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const require = createRequire( import.meta.url );

module.exports = {
export default {
// https://webpack.js.org/configuration/entry-context/
entry: './app.js',

Expand Down Expand Up @@ -294,7 +299,6 @@ You can start with the {@link examples/builds/classic-editor classic editor} wit
```bash
npm install --save \
@ckeditor/ckeditor5-dev-utils \
@ckeditor/ckeditor5-editor-classic \
@ckeditor/ckeditor5-essentials \
@ckeditor/ckeditor5-paragraph \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ Prior to version 42.0.0, there were several ways to install CKEditor 5, eac
Here is a code example showing one of the possible setups using the old installation methods:

```js
// webpack.config.js
const path = require( 'path' );
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
// webpack.config.mjs

module.exports = {
import path from 'path';
import { createRequire } from 'module';
import { styles } from '@ckeditor/ckeditor5-dev-utils';
import { CKEditorTranslationsPlugin } from '@ckeditor/ckeditor5-dev-translations';

const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );

const require = createRequire( import.meta.url );

export default {
entry: './src/index.js',
output: {
path: path.resolve( __dirname, 'dist' ),
Expand Down

0 comments on commit cdbcd7e

Please sign in to comment.