Code Monkey home page Code Monkey logo

Comments (14)

incompletude avatar incompletude commented on August 19, 2024 1

@brunocodutra The default behaviour for many webpack plugins is to keep the path unchanged (according to the prefix) if no publicPath is offered. Why add a reference to the root folder if no path is offered?

from webapp-webpack-plugin.

viiiprock avatar viiiprock commented on August 19, 2024

I have the same issue :(

from webapp-webpack-plugin.

brunocodutra avatar brunocodutra commented on August 19, 2024

By definition, URLs to assets are composed as '${publicPath}/${prefix}/${assetName}, where publicPath is configured by Webpack: https://webpack.js.org/guides/public-path/

If it's not set, it defaults to /, so if you need it to be relative, then just set it as appropriate.

from webapp-webpack-plugin.

viiiprock avatar viiiprock commented on August 19, 2024

@brunocodutra I tried to add publicPath: path.join(__dirname, "dist") and still locate to root, my js and css works fine.
screen shot 2018-06-28 at 8 50 50 pm

from webapp-webpack-plugin.

brunocodutra avatar brunocodutra commented on August 19, 2024

This is probably due to #105, could you retry with caching disabled?

from webapp-webpack-plugin.

brunocodutra avatar brunocodutra commented on August 19, 2024

It defaults to '/' because otherwise it would produce broken output by default, since browserconfig.xml does not support relative paths, see https://stackoverflow.com/questions/27116378/mstile-image-location-specification

from webapp-webpack-plugin.

octatone avatar octatone commented on August 19, 2024

I am running into this issue as well. We use <base href="somecdn.net/somebuild/" /> in our index.html to control delivery of assets. HTMLWebpackPlugin does not add a leading slash to its injected resources, only webapp-webpack-plugin is adding this leading slash to its injected resources in index.html.

This is inconsistent with HTMLWebpackPlugin's behavior and makes it impossible for us to use webapp-webpack-plugin for favicon injection into index.html.

from webapp-webpack-plugin.

octatone avatar octatone commented on August 19, 2024

It seems like the path should only get fixed up when rendering browserconfig.xml, rather than breaking expected behavior for injected assets in HTMLWebpackPlugin in index.html

from webapp-webpack-plugin.

brunocodutra avatar brunocodutra commented on August 19, 2024

Are you able to set publicPath: ''?
Does that fix the issue for you?

from webapp-webpack-plugin.

sheerun avatar sheerun commented on August 19, 2024

@brunocodutra I can't set publicPath because it's controlled by Next.js framework I'm using. Is it possible to override this option only for webapp-webpack-plugin?

from webapp-webpack-plugin.

brunocodutra avatar brunocodutra commented on August 19, 2024

@sheerun could you give more details, e.g. what output do you get and what you expect instead?

from webapp-webpack-plugin.

korylprince avatar korylprince commented on August 19, 2024

This is still not ideal behavior.

My use case is building static files to be hosted under subfolders, e.g. http://example.com/app1, http://example.com/app2, etc. This makes relative paths incredibly useful, because it decouples the app from the deployment.

I can't find any way to do that with webapp-webpack-plugin without manually setting the subfolder in the build configuration meaning I must know the subfolder ahead of time.

The closest I can get is doing something like this:

    new WebappWebpackPlugin({
        logo: "/path/to/icon.png"
        outputPath: "icons/",
        publicPath: "icons/",
        prefix: "",
    }),

This will cause all the icons to be resolved relatively like normal, but the manifest files don't take into account the relative path, so the browser will request something like icons/icons/file... instead of icons/file....

If the manifest files could be made to reference the files relatively, or even give another option similar to publicPath but just for manifests, it would fix this issue.

from webapp-webpack-plugin.

brunocodutra avatar brunocodutra commented on August 19, 2024

@korylprince doesn't the following do what you expect, i.e. resolve icons relative to the manifest file?

    new WebappWebpackPlugin({
        logo: "/path/to/icon.png"
        outputPath: "icons/",
        publicPath: ".",
        prefix: "",
    }),

Note however that relative paths in manifest files may not always work https://stackoverflow.com/questions/27116378/mstile-image-location-specification

from webapp-webpack-plugin.

korylprince avatar korylprince commented on August 19, 2024

That fixes the manifest problem, but now all the files are referenced in index.html without the icon/ so it's just shifting the problem.

I understand the problem with browserconfig.xml, but I'm in agreement with others that have posted here that the default behavior should be the more useful and any corner cases should be handled for the weird cases like browserconfig.xml with additional config or something.

Because I didn't say it before, thanks for the project!

from webapp-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.