Skip to content

TypeError: Cannot read property 'length' of undefined #4

@thescientist13

Description

@thescientist13

Configuration

const WebappManifest = require('webapp-manifest-plugin');
const WebappManifestPlugin = WebappManifest.default;
const FAVICON_PLUGIN = WebappManifest.FAVICON_PLUGIN;

// ...

plugins: [
    // ...

    new FaviconsWebpackPlugin({
      logo: './components/bootstrap/images/pvd-geeks-logo.png',
      emitStats: true,
      prefix: 'icons/',
      statsFilename: 'icons/stats.json',
      inject: true,
      title: 'Providence Geeks',
      background: '#efefef',
      icons: {
        android: true,
        appleIcon: true,
        appleStartup: true,
        coast: false,
        favicons: true,
        firefox: true,
        opengraph: true,
        twitter: true,
        yandex: true,
        windows: true
      }
    }),

    new WebappManifestPlugin({
      name: 'Providence Geeks',
      shortName: 'PVD Geeks',
      description: 'Hello World',
      dir: 'auto',
      lang: 'en-US',
      display: 'standalone',
      orientation: 'any',
      startUrl: '/',
      backgroundColor: '#fff',
      themeColor: '#fff',
      icons: FAVICON_PLUGIN,
      preferRelatedApplications: false,
      relatedApplications: [],
      scope: '/'
    }),

Note: I am also using html-webpack-plugin, but in conjunction with webpack-merge.

Error

ERROR in   TypeError: Cannot read property 'length' of undefined

  - index.js:56 Compilation.<anonymous>
    [website-frontend]/[webapp-manifest-plugin]/lib/index.js:56:25

  - Tapable.js:270
    [website-frontend]/[webpack]/[tapable]/lib/Tapable.js:270:14

  - index.js:61 Compilation.<anonymous>
    [website-frontend]/[favicons-webpack-plugin]/index.js:61:11

  - Tapable.js:272 Compilation.applyPluginsAsyncWaterfall
    [website-frontend]/[webpack]/[tapable]/lib/Tapable.js:272:13

  - util.js:16 Compilation.tryCatcher
    [website-frontend]/[bluebird]/js/release/util.js:16:23


  - index.js:645
    [website-frontend]/[html-webpack-plugin]/index.js:645:12

  - index.js:142
    [website-frontend]/[html-webpack-plugin]/index.js:142:16

  - util.js:16 tryCatcher
    [website-frontend]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [website-frontend]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [website-frontend]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [website-frontend]/[bluebird]/js/release/promise.js:614:10

  - promise.js:693 Promise._settlePromises
    [website-frontend]/[bluebird]/js/release/promise.js:693:18

  - async.js:133 Async._drainQueue
    [website-frontend]/[bluebird]/js/release/async.js:133:16

  - async.js:143 Async._drainQueues
    [website-frontend]/[bluebird]/js/release/async.js:143:10

  - async.js:17 Immediate.Async.drainQueues
    [website-frontend]/[bluebird]/js/release/async.js:17:14

The issue appears to be with this section of code

  compilationHook() {
    const config = this.config;
    return function hook(compilation) {
      compilation.plugin(HTML_PLUGIN_BEFORE_PROCESS, (htmlData, callback) => {
        let publicPath = this.options.output.publicPath;
        if (publicPath.length > 0 && publicPath[publicPath.length - 1] !== '/') { // <-- breaks on this line
          publicPath += '/';
        }

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions