CKEditor 4 build (minify and uglify)

前端 未结 2 1946
走了就别回头了
走了就别回头了 2021-02-01 18:06

In our build process (using grunt), we concatenate, minify and uglify all our scripts into a single one (also meaning a single request only).

Now CKEditor 4 seems to be

2条回答
  •  误落风尘
    2021-02-01 18:28

    I implemented suggestions 2 and 3 from Reinmar's answer - here's how I did it:

    1. "Editor UI stylesheet file can be perhaps concatenated with your page's stylesheets, but you'll have to find a way to prevent editor from loading it by itself"
    var swap = CKEDITOR.skin.loadPart;
    CKEDITOR.skin.loadPart = function(res, callback) {
        if (res == 'editor') {
            console.log('Ignoring editor.css load');
            callback && callback();
            return;
        }
        swap(res, callback);
    }
    

    I then bundled editor.css into my bundled file.

    1. Contents stylesheet - you can remove it even if you use framed editor, but you'll need to style contents using the fullPage feature (not recommended).
    // I copied the content.css from ckeditor-dev and loaded it into contentCss.
    var contentCss = 'put your css here';
    
    var config = {
        // Other things here
        // ...
    
        contentCss: contentCss
    };
    
    ckeditor.replace(element, config);
    

    Both are done at initialization time (in my code they're in the function that calls ckeditor.replace, as shown in 3).

    These are most certianly hacks, but for my current use the optimizations enabled by these hacks are worth it.

    Also, in lieu of implementing suggestion 1., I prevent other js files from loading by setting customConfig: '' and stylesSet: false in the config.

提交回复
热议问题