strapi / documentation

Strapi Documentation
https://docs.strapi.io
Other
1.03k stars 1.11k forks source link

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

Open mauriciabad opened 1 year ago

mauriciabad commented 1 year ago

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)

https://github.com/strapi/documentation/pull/1000

mauriciabad commented 1 year ago

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

pwizla commented 10 months ago

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.

101sam commented 10 months ago

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 commented 4 months ago

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;
};

https://github.com/strapi/strapi/issues/11912

pwizla commented 4 months ago

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