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

[Bug]: Favicon instructions lead to TypeScript errors #1829

Open
mauriciabad opened this issue Aug 23, 2023 · 5 comments
Open

[Bug]: Favicon instructions lead to TypeScript errors #1829

mauriciabad opened this issue Aug 23, 2023 · 5 comments
Assignees

Comments

@mauriciabad
Copy link

mauriciabad commented Aug 23, 2023

Link to the documentation page or resource

https://docs.strapi.io/dev-docs/admin-panel-customization#favicon

Describe the bug

The instructions about adding a favicon have errors, and it doesn't work when you copy and paste it in a new project.

This is the error that appears:

Cannot find module './extensions/favicon.png' or its corresponding type declarations.ts(2307)

Additional context

This is the code:

import favicon from './extensions/favicon.png';

export default {
  config: {
    // replace favicon with a custom icon
    head: {
      favicon: favicon,
    },
  }
}

Suggested improvements or fixes

Although it is a typical TS problem solvable by the developer, but documentation code shouldn't have errors. Nowhere in strapi's documentation, it is explained how to deal with this.

Related issue(s)/PR(s)

#1000

@mauriciabad
Copy link
Author

Moreover, I'd like to add that the favicon should be added from the UI as well as the other icons...

@pwizla pwizla added the issue: docs/code example Issues about incorrect code examples found on docs.strapi.io label Oct 18, 2023
@pwizla pwizla self-assigned this Oct 18, 2023
@pwizla
Copy link
Collaborator

pwizla commented Dec 13, 2023

Hi! I will slightly update the code example, but I'm not sure what went wrong in your use case, because I've just tested it and it works 🤷
Screenshot 2023-12-13 at 15 46 37

I'll close this issue for now, but feel free to reopen it if you have any question.

@pwizla pwizla closed this as completed Dec 13, 2023
@pwizla pwizla added status: can not reproduce Not enough information to reproduce and removed issue: docs/code example Issues about incorrect code examples found on docs.strapi.io labels Dec 13, 2023
@101sam
Copy link

101sam commented Dec 28, 2023

Sam issue clean strapi (JS)

yarn create strapi-app my-project --quickstart

Follow the steps in the documentation https://docs.strapi.io/dev-docs/admin-panel-customization#favicon:

import favicon from "./extensions/favicon_2023.png";


const config = {
  head: {
    favicon: favicon,
  },

};

const bootstrap = (app) => {
  console.log(app);
};

export default {
  config,
  bootstrap,
};

2023-12-28_04-01-11

@ntuong196
Copy link

ntuong196 commented Jun 27, 2024

I had a similar issue. But it was solved here.
Also, add the extension folder in webpack config:

// path: ./src/admin/webpack.config.js

'use strict';

const _ = require('lodash');
const path = require('path');

/* eslint-disable no-unused-vars */
module.exports = (config, webpack) => {
  // this includes the folder ./src/admin/extensions with the alias assets
  _.set(config, 'resolve.alias.assets', path.resolve(__dirname, './extensions'));
  return config;
};

strapi/strapi#11912

@pwizla
Copy link
Collaborator

pwizla commented Jun 27, 2024

Thanks for reporting, we'll reference this in docs soon. Re-opening the issue to ensure it's not missed.

@pwizla pwizla reopened this Jun 27, 2024
@pwizla pwizla removed the status: can not reproduce Not enough information to reproduce label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants