admin管理员组

文章数量:1326309

I have an MS MVC deployment that is looking for a subscript for TinyMCE "theme.js" and not finding it because the file is theme.min.js. How do I get MVC to look for the minified file?

The tinymce file is tinyMCE.min.js, so it is finding that one. Is this a problem with setting TinyMCE or MS MVC?

Long explanation : We are in the process of implementing TinyMCE on a Microsoft MVC page. It was working locally but would not run when deployed to the server. It was failing with a 404, file not found for the file : PROJECT_ROOT/bundles/themes/modern/theme.js

This was not the location of the theme file it was looking for and after a little research I found out that you needed to set the tinymce.baseURL property. When I did this it helped a little by changing the location in the error to the actual location of the file : PROJECT_ROOT/Scripts/libs/tinymce/themes/modern/theme.js

The problem is that for some reason it was looking for the un-minified file theme.js and not theme.min.js. If I change the name to theme.js it works.

I thought that MVC and/or TinyMCE would do some magic to get the right name. Is there a setting I need to change?

I have an MS MVC deployment that is looking for a subscript for TinyMCE "theme.js" and not finding it because the file is theme.min.js. How do I get MVC to look for the minified file?

The tinymce file is tinyMCE.min.js, so it is finding that one. Is this a problem with setting TinyMCE or MS MVC?

Long explanation : We are in the process of implementing TinyMCE on a Microsoft MVC page. It was working locally but would not run when deployed to the server. It was failing with a 404, file not found for the file : PROJECT_ROOT/bundles/themes/modern/theme.js

This was not the location of the theme file it was looking for and after a little research I found out that you needed to set the tinymce.baseURL property. When I did this it helped a little by changing the location in the error to the actual location of the file : PROJECT_ROOT/Scripts/libs/tinymce/themes/modern/theme.js

The problem is that for some reason it was looking for the un-minified file theme.js and not theme.min.js. If I change the name to theme.js it works.

I thought that MVC and/or TinyMCE would do some magic to get the right name. Is there a setting I need to change?

Share Improve this question asked Nov 6, 2018 at 15:06 Terry HTerry H 3405 silver badges21 bronze badges 1
  • With TinyMCE 6 it's the other way around: it's really hard to get it to load skin from an URL that doesn't include coded .min in the middle. – Mikko Rantalainen Commented Dec 1, 2022 at 13:30
Add a ment  | 

3 Answers 3

Reset to default 9

You need to set tinymce.suffix = '.min'; before you init TinyMCE

tinymce.suffix = '.min';
tinymce.baseURL = '/js/tinymce';
tinymce.init({
    selector: '#editor',
    menubar: false,
    plugins: 'code' 
});

TinyMCE should work out to load minified (or non-minified) files based on which TinyMCE file you load (tinymce.js or tinymce.min.js).

Not sure what's happening in your case but that logic appears to be failing.

If you grab the DEV package from https://www.tiny.cloud/get-tiny/self-hosted/ it would e with both the minified and non-minified versions of each file so the editor would find what it needs at runtime.

Note: The code in the minified and non-minified files functions just the same so from a functionality perspective it does not really matter if theme.min.js or theme.js code is loaded. It only add ~200K to the file size so even that is immaterial.

I think I found the solution for this. There is a property you can set in the tinymce object called "suffix" that resolved this for me.

So, for the first part I set a rootURL property in the page calling TinyMCE, and then added the line tinymce.baseURL = rootURL + 'Scripts/libs/tinymce' just before the tinymce.init.

Then, to get it to find the theme.min.js set tinymce.suffix = '.min'

This seems to have resolved the issue. Not sure if this is a hack solution but it is working. If anyone has a better way to do it please let me know.

本文标签: javascriptTinyMCE MS MVC looking for nonminified fileStack Overflow