Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 with CSS minifiers #4

Closed
JohnMcAvinue opened this issue Aug 25, 2017 · 4 comments
Closed

Version 2 with CSS minifiers #4

JohnMcAvinue opened this issue Aug 25, 2017 · 4 comments

Comments

@JohnMcAvinue
Copy link

Hi,

I have upgraded all packages to the latest versions but I'm struggling with the configuration side of things. I have moved the Javascript config into code:

`public static void Configure(JsEngineSwitcher engineSwitcher)
{
engineSwitcher.EngineFactories
//.AddChakraCore()
//.AddJint()
//
.AddMsie(new MsieSettings
{
UseEcmaScript5Polyfill = true,
UseJson2Library = true
});
// .AddV8();

        engineSwitcher.DefaultEngineName = MsieJsEngine.EngineName;
    }`

I've left the CSS config in the web.config like this:

<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd"> <core> <css defaultMinifier="WgCssMinifier"> <translators> <add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" /> </translators> <postProcessors> <add name="UrlRewritingCssPostProcessor" type="BundleTransformer.Core.PostProcessors.UrlRewritingCssPostProcessor, BundleTransformer.Core" useInDebugMode="false" /> </postProcessors> <minifiers> <add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" /> <add name="WgCssMinifier" type="BundleTransformer.WG.Minifiers.WgCssMinifier, BundleTransformer.WG" /> </minifiers> <fileExtensions> <add fileExtension=".css" assetTypeCode="Css" /> </fileExtensions> </css> </core> </bundleTransformer>

However, when I try to run my application I get a validation error on this line:

@Scripts.Render("~/bundles/admin/application/js")

These assets are not scripts: /Content/admin/theme/vendor/jquery/jquery-1.11.1.min.js, /Content/admin/theme/vendor/jquery/jquery_ui/jquery-ui.js, /Scripts/jquery.validate.min.js, /Scripts/jquery.validate.unobtrusive.min.js

@Taritsyn
Copy link
Owner

Hello, John!

These assets are not scripts: /Content/admin/theme/vendor/jquery/jquery-1.11.1.min.js, /Content/admin/theme/vendor/jquery/jquery_ui/jquery-ui.js, /Scripts/jquery.validate.min.js, /Scripts/jquery.validate.unobtrusive.min.js

This error occurred, because you have removed the following settings:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	...
	<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
		<core>
			...
			<js>
				<translators>
					<add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
				</translators>
				<minifiers>
					<add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
				</minifiers>
				<fileExtensions>
					<add fileExtension=".js" assetTypeCode="JavaScript" />
				</fileExtensions>
			</js>
			...
		</core>
		...
	</bundleTransformer>
	...
</configuration>

...
engineSwitcher.DefaultEngineName = MsieJsEngine.EngineName;
...

This setting does not apply to the Bundle Transformer. JS engine needs to be specified for each specific module, but in your case I do not see modules, that require the JavaScript Engine Switcher library. Only the following modules require installation of the JavaScript Engine Switcher: Less, CoffeeScript, TypeScript, Hogan, Handlebars, Autoprefixer, Packer, UglifyJs, Csso and CleanCss.

I have upgraded all packages to the latest versions but I'm struggling with the configuration side of things.

I recommend you to read the “How to upgrade applications to version 2.X” section of the JavaScript Engine Switcher's documentation. Also see a JsEngineSwitcherConfig.cs and Global.asax.cs files from the sample project.

@JohnMcAvinue
Copy link
Author

Hi Taritsyn,

Thanks for such a prompt reply and for sharing your hard work!

I removed the configuration in the web.config as I interpreted the upgrade guide as saying that I had to from this line:

"Now during configuration instead of the declarative approach (using the configuration file) is used in the imperative approach (using the program code)."

I was using UglifyJs so I do think I need that. I'll have a look at the sample later on and replicate what's in there.

Thank you!

@Taritsyn
Copy link
Owner

I removed the configuration in the web.config as I interpreted the upgrade guide as saying that I had to from this line:

"Now during configuration instead of the declarative approach (using the configuration file) is used in the imperative approach (using the program code)."

You misunderstood this text. This statement applies only to the JavaScript Engine Switcher library (in text even specified the configuration sections, that need to be removed). Bundle Transformer still uses a declarative approach (see the “Configuration settings” section of documentation).

I was using UglifyJs so I do think I need that.

Yes, this module requires installation of the JavaScript Engine Switcher library.

@JohnMcAvinue
Copy link
Author

This worked fine thanks. I had problems using Web Grease on Azure as an App Service. Will open a separate ticket to track that though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants