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

Issues with *.vue #6762

Open
jaliao opened this issue Jul 24, 2020 · 8 comments
Open

Issues with *.vue #6762

jaliao opened this issue Jul 24, 2020 · 8 comments
Milestone

Comments

@jaliao
Copy link

jaliao commented Jul 24, 2020

I have a project using xxx.vue.
I put the xxx.vue under the folder named wwwroot
But it return 404 from liquid file when I browse this file using Chrome.
the other static file is correct return.

How to config static file list in Orchard Core.

thanks
Justin

@jaliao
Copy link
Author

jaliao commented Jul 24, 2020

How to add a new FileExtensionContentTypeProvider in OC project?

@ns8482e
Copy link
Contributor

ns8482e commented Jul 24, 2020

@jaliao Are you using Vue CLI?

@sebastienros
Copy link
Member

Unknown file types are not served by default in ASP.NET. We should document how to configure the static file provider (@jtkech can you provide an example?), either to accept all files (ServerUnknownFileTypes) or by adding a custom mime type mapping.

@sebastienros sebastienros added this to the 1.0.x milestone Jul 30, 2020
@jtkech
Copy link
Member

jtkech commented Jul 31, 2020

@sebastienros i will look at it asap

@jtkech
Copy link
Member

jtkech commented Jul 31, 2020

@jaliao @sebastienros

First you would need a custom IContentTypeProvider, e.g.

    public class CustomContentTypeProvider : IContentTypeProvider
    {
        private readonly FileExtensionContentTypeProvider _contentTypeProvider =
            new FileExtensionContentTypeProvider();

        public bool TryGetContentType(string subpath, out string contentType)
        {
            if (_contentTypeProvider.TryGetContentType(subpath, out contentType))
            {
                return true;
            }

            // Here do your custom mapping

            return false;
        }

Look at this source code to see how to do your custom mapping

Then at the app level so that it is related to all static files providers

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddOrchardCms();

        services.Configure<StaticFileOptions>(o =>
            o.ContentTypeProvider = new CustomContentTypeProvider());
    }

Or still from the app but at the tenant level so that it is not related to the app level static files but e.g. to the static files embedded in modules. Notice the negative order so that the options are configured before the tenant uses it.

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddOrchardCms()
            .ConfigureServices( s =>
                s.Configure<StaticFileOptions>(o =>
                    o.ContentTypeProvider = new CustomContentTypeProvider()
                )
            ,
            order: -100);
    }

Finally the same can be done in a custom module, e.g. when a feature is enabled, in that case your module main startup, or the one that is tied to a given feature, would need to override the Order property with a negative value as above, and then do the same configuration in its ConfigureServices() method.

@jaliao
Copy link
Author

jaliao commented Jul 31, 2020

thank you : )

@pholly
Copy link

pholly commented Oct 1, 2020

.vue files should not be served directly to the browser. There needs to be a build step that outputs .js files. By default the vue cli includes npm run dev and npm run build to build and output your app.

@jptissot
Copy link
Member

jptissot commented Oct 1, 2020

Maybe you could modify the Gulp pipeline to compile these like we compile assets ?

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

No branches or pull requests

6 participants