Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FaviconsWebpackPlugin won't generate icons, inject them into head #3068

Closed
1 task done
schoenwaldnils opened this issue Oct 10, 2017 · 3 comments
Closed
1 task done

Comments

@schoenwaldnils
Copy link
Contributor

schoenwaldnils commented Oct 10, 2017

  • I have searched the issues of this repository and believe that this is not a duplicate.

my config (tidied)

// next.config.js
import HtmlWebpackPlugin from 'html-webpack-plugin';
import FaviconsWebpackPlugin from 'favicons-webpack-plugin';

module.exports = {
  webpack: (config, { dev }) => {
    config.plugins.push(
      new FaviconsWebpackPlugin({
        logo: './static/assets/images/favicon.png',
        inject: true,
      }),
      new HtmlWebpackPlugin(),
    );

    return config;
  },
};
// pages/_document.js
import React from 'react';
import Document, { Head, Main, NextScript } from 'next/document';

export default class SmediaDocument extends Document {
  render() {
    return (
      <html lang="en">
        <Head>
          <meta charSet="utf-8" />
          <meta content="IE=edge" httpEquiv="X-UA-Compatible" />
          <meta content="width=device-width,initial-scale=1" name="viewport" />
          <title>Schoenwald.media</title>
          <meta name="description" content="Thoughts on CSS, JS, and overall clean code." />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </html>
    );
  }
}

I'd expect that the favicons-webpack-plugin generates the icons, and the html-webpack-plugin inject it in the <head/> of the page. Which it doesn't.

Steps to Reproduce

  1. Checkout https://github.com/schoenwaldnils/blog
  2. Set up .envfile with
HOST=localhost
PORT=3000
  1. docker-compose up

Environment

Tech Version
next ~4.0.0-beta.4
html-webpack-plugin ~2.30.1
favicons-webpack-plugin 0.0.7
node 8.4.0
OS mhart/alpine-node:8.4.0
@MacKentoch
Copy link

Does it run production?
In dev (npm run dev) webpack won't run your plugins (see .next directory content).

My issue is to found out a way to make sw-precache-webpack-plugin working even in dev (only works in production).

@mtford90
Copy link

mtford90 commented Mar 9, 2018

Hmmm I'm facing similar issues with next 5 despite universal webpack. Similar setup to above:

	return Object.assign({}, nextConfig, {
		webpack(config, options) {
			config.plugins.push(
				new FaviconsWebpackPlugin({
					logo: './static/img/favicon.png',
					inject: true
				})
			)

			config.plugins.push(
				new HtmlWebpackPlugin()
			)
                }
        }

I see nothing injected when running in both prod & dev

Am I perhaps missing something important? @timneutkens :P

I do have a custom _document.js... perhaps I need to modify that in some way to inject the necessary tags within <head/> - I can't see anything in the context/pageContext however assuming that's the correct place

@timneutkens
Copy link
Member

new HtmlWebpackPlugin() this does nothing in Next. Next uses React, not html, as a renderer.

The favicons will probably end up somewhere in the .next folder.

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants