Maxim V. Pavlov
Maxim V. Pavlov

Reputation: 10509

How to let js plugins survice ASP.NET javascript optimization at release

I have a ckeditor plugin in my ASP.NET MVC 4 web site. The plugin is in the Content folder of an Area.

When working in debug environment, everything is fine. When I am deploying to a production server, js optimization kicks in, that along with a CliendDependency framework I use optimizes javascripts to serve less files, resulting in less connections to server. That is fine, except for the fact, that javascript plugins, like ckeditor, in my case, reference other .js files internally when rendering themselves onth the page. As a result, I have a few .js files being requested by the page's javascript as if they are to be in the root folder of the site (optimized JS files come "as if" from root). But in reality, the requested files are deep within the folder structure.

Is there a more conceptual workaround to this problem other then disabling JS optimization? Some custom rules I can set? Or do I just copy the required files to the root folder and forget about the problem?

Upvotes: 2

Views: 189

Answers (1)

dove
dove

Reputation: 20674

You can continue to use optimisation and bundling with CkEditor.

You just need to set the following global for your ckeditor folder

CKEDITOR_BASEPATH = ApplicationPath + '/scripts/ckeditor/ckeditor_3.5.3/';

and when you initialise a ckeditor set the baseHref, e.g.

CKEDITOR.replace(editorName, {
      baseHref: CKEDITOR_BASEPATH, 
}

Upvotes: 1

Related Questions