pankajpatel / fontgen-loader

Forked from https://github.com/DragonsInn/fontgen-loader
5 stars 1 forks source link

Return the option to pull publicPath from webpack config #6

Closed IlyaSemenov closed 1 year ago

IlyaSemenov commented 6 years ago

As of 0.3.0, the only way to push a custom public path is to hard-code it in each font config.

This is ridiculous and it breaks the principle of the separation of concerns. A font config must be aware about the icons and fonts stuff (formats, CSS prefixes and such) but not about the delivery internals. If I want to switch the minified assets path, or use a CDN, this doesn't have anything to do with the icons, and should not require updating the font config.

In 0.2.9, I was using this:

const outputPath = '...'
const publicPath = '/min'

module.exports = {
  output: {
    path: outputPath,
    publicPath: publicPath,
  },
  plugins: [
    new webpack.LoaderOptionsPlugin({
      options: {
        output: {
          // for font-gen-loader - this is ignored in 0.3.0!
          publicPath
        }
      }
    }),
  ],
  module: {
    rules: [
      {
        test: /\.font\.(js|json)$/,
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: ['css-loader', 'font-gen-loader']
        })
      },
...

As of 0.3.0, it's not possible anymore.

Ideally, font-gen-loader should pick webpack.output.publicPath automatically.

IlyaSemenov commented 6 years ago

For what it's worth, I switched to https://github.com/jeerbl/webfonts-loader.

It suffers from similar problems when handling publicPath (https://github.com/jeerbl/webfonts-loader/issues/36, https://github.com/jeerbl/webfonts-loader/pull/37) but at least I still can use LoaderOptionsPlugin fallback.

pankajpatel commented 6 years ago

I still can't recall the reason why I removed this capability.

pankajpatel commented 6 years ago

7 should fix this