Shopware 6 path of custom npm dependency cannot be resolved inside theme plugin

Viewed 59

I tried to use a custom npm dependency by following this tutorial:

https://www.youtube.com/watch?v=wfBuWdff35c

In my case, I would like to integrate fontawesome.

When I try to import the js files to my main.js I get the following message:

ERROR in /home/user/projects/xy/custom/plugins/customTheme/src/Resources/app/storefront/src/main.js Module not found: Error: Can't resolve '@fortawesome/fontawesome-free/js' in '/home/user/projects/xy/custom/plugins/customTheme/src/Resources/app/storefront/src'

My webpack.config.js

const { join, resolve } = require('path');

module.exports = () => {
    return {
        resolve: {
            alias: {
                '@fortawesome': resolve(
                    join(__dirname, '..', 'node_modules', '@fortawesome'),
                ),
            },
        },
    };
};

and my import:

import { all } from '@fortawesome/fontawesome-free/js';

Does anybody know why the path can't be resolved?

1 Answers

Don't know the package but it looks like what you want to do should work like this:

import '@fortawesome/fontawesome-free/js/all.js';
Related