Skip to content

The svg file is not created when using an alias for the directory containing your SVG files #12

@nikosdrog

Description

@nikosdrog

Detailed description

Hello guys. I need your input please. The problem is that the svg file is not created.
Βelow you will see what I have done.
I would be grateful for any help.

webpack.config.js

module.exports = {
    resolve: {
        alias: {
            '@createSvg': path.resolve(__dirname, './resources/img/icons')
        }
    }
};

webpack.mix.js

require('laravel-mix-svg-sprite');

Config.svgSprite = {
    loaderOptions: {
        extract: true
    },
    pluginOptions: {
        plainSprite: true
    }
};

mix.js('resources/js/index.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .svgSprite(
        '@createSvg',
        'public/img/sprite.svg'
    )
    .extract();

index.js (my app.js file)

function requireAll(r) {
    r.keys().forEach(r);
}

requireAll(require.context('@createSvg', true, /\.svg$/));

Your environment

  • Version used (e.g. Node 10 and Laravel Mix 5.0.1):
  • Operating system and version Windows 10:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions