patrickhulce / fontmin-webpack

Minifies icon fonts to just the used glyphs.
MIT License
139 stars 19 forks source link

DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead #11

Closed orzechdev closed 5 years ago

orzechdev commented 6 years ago

I got the following output (using latest version v2.0.1 and webpack 4.16.5):

(node:21428) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
    at FontminPlugin.apply (D:\tutor\node_modules\fontmin-webpack\lib\index.js:173:14)
    at webpack (D:\tutor\node_modules\webpack\lib\webpack.js:37:12)
    at options.map.options (D:\tutor\node_modules\webpack\lib\webpack.js:28:55)
    at Array.map (<anonymous>)
    at webpack (D:\tutor\node_modules\webpack\lib\webpack.js:28:40)
    at processOptions (D:\tutor\node_modules\webpack-cli\bin\cli.js:441:16)
    at yargs.parse (D:\tutor\node_modules\webpack-cli\bin\cli.js:528:3)
    at Object.parse (D:\tutor\node_modules\webpack-cli\node_modules\yargs\yargs.js:563:18)
    at D:\tutor\node_modules\webpack-cli\bin\cli.js:219:8
    at Object.<anonymous> (D:\tutor\node_modules\webpack-cli\bin\cli.js:530:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\tutor\node_modules\webpack\bin\webpack.js:165:2)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at findNodeScript.then.existing (C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx\index.js:268:14)
    at <anonymous>
D:\tutor\node_modules\ttf2woff2\jssrc\ttf2woff2.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=
typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_
NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePa
th=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&

TypeError: content.match is not a function
    at _.map.filter.map.item (D:\tutor\node_modules\fontmin-webpack\lib\index.js:93:33)
    at arrayMap (D:\tutor\node_modules\lodash\lodash.js:639:23)
    at Function.map (D:\tutor\node_modules\lodash\lodash.js:9554:14)
    at interceptor (D:\tutor\node_modules\lodash\lodash.js:16991:35)
    at Function.thru (D:\tutor\node_modules\lodash\lodash.js:8795:14)
    at D:\tutor\node_modules\lodash\lodash.js:4388:28
    at arrayReduce (D:\tutor\node_modules\lodash\lodash.js:683:21)
    at baseWrapperValue (D:\tutor\node_modules\lodash\lodash.js:4387:14)
    at LodashWrapper.wrapperValue (D:\tutor\node_modules\lodash\lodash.js:9050:14)
    at FontminPlugin.findUnicodeGlyphs (D:\tutor\node_modules\fontmin-webpack\lib\index.js:104:8)
    at FontminPlugin.onAdditionalAssets (D:\tutor\node_modules\fontmin-webpack\lib\index.js:154:30)
    at compilation.plugin.done (D:\tutor\node_modules\fontmin-webpack\lib\index.js:175:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\tutor\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (D:\tutor\node_modules\tapable\lib\Hook.js:35:21)
    at hooks.optimizeTree.callAsync.err (D:\tutor\node_modules\webpack\lib\Compilation.js:1276:32)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\tutor\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (D:\tutor\node_modules\tapable\lib\Hook.js:35:21)
    at Compilation.seal (D:\tutor\node_modules\webpack\lib\Compilation.js:1213:27)
    at hooks.make.callAsync.err (D:\tutor\node_modules\webpack\lib\Compiler.js:547:17)
    at _err0 (eval at create (D:\tutor\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:11:1)
    at _addModuleChain (D:\tutor\node_modules\webpack\lib\Compilation.js:1064:12)
    at processModuleDependencies.err (D:\tutor\node_modules\webpack\lib\Compilation.js:980:9)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

It seems like the problem is with the following: https://github.com/webpack/webpack/issues/6568#issuecomment-377491754

Any idea? Maybe I'm doing something wrong? This is my config:

const path = require('path');
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const FontminPlugin = require('fontmin-webpack')

var config = {
  mode: 'development',
  module: {},
};

var jsConfig = Object.assign({}, config,{
...
}

var cssConfig = Object.assign({}, config, {
  name: 'css',
  entry: {
    materialize: './src/AppBundle/Resources/scss/materialize.scss'
  },
  output: {
    path: path.join(__dirname, 'temp/js'),
    filename: '[name].min.js'
  },
  module: {
    rules: [
      {
        test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
        loader: 'file-loader?name=fonts/[name].[ext]'
      },
      {
        test: /\.scss$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: '[name].min.css',
              outputPath: '../../web/css'
            }
          },
          {
            loader: 'extract-loader'
          },
          {
            loader: 'css-loader'
          },
          {
            loader: 'postcss-loader'
          },
          {
            loader: 'sass-loader?sourceMap'
          }
        ]
      }
    ]
  },
  plugins: [
    new FontminPlugin({
      autodetect: true,
    }),
  ],
});

module.exports = [
  cssConfig, jsConfig,
];

And the scss file:

...
@font-face {
  font-family: 'icomoon';
  src:  url('../fonts/icomoon/icomoon.eot?iex0o3');
  src:  url('../fonts/icomoon/icomoon.eot?iex0o3#iefix') format('embedded-opentype'),
  url('../fonts/icomoon/icomoon.ttf?iex0o3') format('truetype'),
  url('../fonts/icomoon/icomoon.woff?iex0o3') format('woff'),
  url('../fonts/icomoon/icomoon.svg?iex0o3#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}
...
koseduhemak commented 5 years ago

Having the same warning too

patrickhulce commented 5 years ago

GH merge messed up the clean history here, but thanks to @mochiya98 for fixing this!

Should no longer receive this deprecation notice in v2.0.2