/* drucafe */

Tuesday, March 8, 2016

Build unminified CKEditor for Drupal 8

Drupal 8 core contains a minified version of CKEditor in core/assets/vendor/ckeditor/ckeditor.js . It's hard to debug e.g. while writing a custom plugin or widget. So on development server it may be useful to have full unminified version.

There are two methods to produce (make, build) unminified ckeditor.js in place of existing, minified version, both described in core/assets/vendor/ckeditor/build-config.js .

First method is to use CKEditor builder on page http://ckeditor.com/builder and this method didn't work for me (after build there were errors, can't remember exactly what errors but it the unminified ckeditor.js just didn't work on my site.

The other method requires to install Git locally and to clone the dev repository. The result ckeditor.js worked perfectly on my site. The build process is described here and has the following steps:

  • Check the version of your existing CKEditor version which came with the D8 install. It's in file core\assets\vendor\ckeditor\changes.md
  • Open Git console in D8 root directory
  • Make a clone of the ckeditor-dev branch from Git into local ckeditor-dev subdirectory:
    git clone https://github.com/ckeditor/ckeditor-dev.git
  • Change directory into the new one: cd ckeditor-dev
  • Upgrade the local clone to the version checked in the first step (from changes.md file). In my case it was 4.5.5, so: git checkout 4.5.5
  • The build configuration which was originally used by D8 is in file core\assets\vendor\ckeditor\build-config.js. So to prepare to make exactly the same build, copy this file to D8root\ckeditor-dev\dev\builder directory.
  • From ckeditor-dev directory, run the builder shell script with the following flags: ./dev/builder/build.sh --skip-omitted-in-build-config --leave-js-unminified
    It will create release subdirectory with unminified ckeditor version
  • Delete the original core\assets\vendor\ckeditor directory
  • Copy the D8root\ckeditor-dev\dev\builder\release\ckeditor directory into core\assets\vendor.
  • You may also copy D8root\ckeditor-dev\dev\builder\build-config.js file into core\assets\vendor\ckeditor, just in case you delete the builder dev and later need to repeat the whole process again.


2 comments:

  1. Dostosuj darmowe Drupal 7 themes dla siebie i uruchom swoją stronę.

    ReplyDelete
  2. Thanks for this, it was very helpful!

    To see the full version names you can do "git tag"

    ReplyDelete