google-fonts-webpack-plugin icon indicating copy to clipboard operation
google-fonts-webpack-plugin copied to clipboard

[email protected] not working with [email protected]

Open swichelecki opened this issue 6 years ago • 9 comments

When I try to use [email protected] with [email protected] and [email protected] I am getting the following errors and the code won't compile:

(node:73383) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

ERROR in   TypeError: cb is not a function
  
  - index.js:116 compilation.plugin
    [site]/[google-fonts-webpack-plugin]/src/index.js:116:5
  
  - Hook.js:35 AsyncSeriesWaterfallHook.lazyCompileHook [as _promise]
    [site]/[tapable]/lib/Hook.js:35:21
  
  - index.js:647 
    [site]/[html-webpack-plugin]/index.js:647:47
  
  - index.js:162 Promise.resolve.then.then.then.then.compilationResult
    [site]/[html-webpack-plugin]/index.js:162:36

Here is the set up in webpack.config:

var GoogleFontsPlugin = require('google-fonts-webpack-plugin');

new GoogleFontsPlugin({
            fonts: [{
              family: 'Open Sans',
              variants: ['400']
            },
            {
              family: 'Ubuntu',
              variants: ['500', '400', '300']
            }]
      })

I have used similar code in webpack v3 and was easily able to use Google fonts.

swichelecki avatar Apr 14 '18 14:04 swichelecki

I have the same issue. anyone can update this?

dashawk avatar May 09 '18 00:05 dashawk

@dashawk

I've imported the Google fonts into my css file like this:

@import url("https://fonts.googleapis.com/css?family=Ubuntu:500,400,300");

@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,600");

That is working fine on dev and production.

swichelecki avatar May 09 '18 12:05 swichelecki

I am having the same issue. Doesn't seem to be compatible with webpack 4. I am new to webpack or else I'd fix this right now. I think it's pretty awesome to just let webpack handle google fonts.

Error: Plugin could not be registered at 'html-webpack-plugin-before-html-generation'. Hook was not found.
BREAKING CHANGE: There need to exist a hook at 'this.hooks'. To create a compatiblity layer for this hook, hook into 'this._pluginCompat'.


ameshkin avatar May 22 '18 23:05 ameshkin

The plugin needs to update html-webpack-plugin, webpack 4 changed the way plugins communicate.

nukeop avatar Jun 02 '18 22:06 nukeop

It seems that #22 fixes the callback issue but still has to be merged (still the deprecation warning for the Tapable.plugin is present but the plugin works with Webpack 4 if @navelpluisje branch is used).

gcalmettes avatar Jun 13 '18 17:06 gcalmettes

@gabiseabra Can you merge the fixes for webpack4?

camflan avatar Jul 26 '18 03:07 camflan

+1

ghost avatar Aug 13 '18 23:08 ghost

I'm running webpack at 4.20.0 and I'm trying to use this plugin at version 0.4.4.

I'm getting the same error as @ameshkin , which renders this plugin unusable in the future.

fridde avatar Jan 13 '19 18:01 fridde

This package has solved this for me https://github.com/beyonk-adventures/google-fonts-webpack-plugin , its compatible with Webpack 4.

Safiyya avatar Jan 30 '19 10:01 Safiyya