Giter Club home page Giter Club logo

Comments (6)

ampedandwired avatar ampedandwired commented on May 8, 2024 3

Fixed in 6ae0e85. You can get a hold of the publicPath through {%=o.webpackConfig.output.publicPath%}.

from html-webpack-plugin.

ampedandwired avatar ampedandwired commented on May 8, 2024

Cheers, glad you like the plugin.

The options object that you pass into the plugin is available in the template, so you could expose the public path through that. Not the cleanest solution and I'll probably add a better way to do this, but it should work. Here is an example:

webpack.config.js

var myPublicPath = '/public/';
var webpackConfig = {
  output: {
    publicPath: myPublicPath
  }
  plugins: [
    new HtmlWebpackPlugin({
      template: './my_index.html',
      publicPath: myPublicPath
    })
  ]
};

my_index.html:

<link rel="stylesheet" href="{%=o.htmlWebpackPlugin.options.publicPath%}{%=o.webpack.assetsByChunkName.client[1]%}"/>

from html-webpack-plugin.

Couto avatar Couto commented on May 8, 2024

That's exactly how I did. :)
But it would be nice not having to duplicate that option (webpack config + HTMLWebpack config), when several people work in the project, someone ought to forget about the duplicated option.

from html-webpack-plugin.

izaakschroeder avatar izaakschroeder commented on May 8, 2024

@Couto see above PR.

from html-webpack-plugin.

Couto avatar Couto commented on May 8, 2024

Great work! I will test those new features later at night. Thanks 👍

from html-webpack-plugin.

lock avatar lock commented on May 8, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from html-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.