swisnl / laravel-mix-svg-sprite

SVG sprite component for Laravel Mix
MIT License
17 stars 2 forks source link

Does this module work? #16

Open PVasili opened 1 month ago

PVasili commented 1 month ago
npm init -y

package.json

{
  "name": "test",
  "version": "1.0.0",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "devDependencies": {
    "laravel-mix": "^6.0.49",
    "laravel-mix-svg-sprite": "^2.0.0",
    "resolve-url-loader": "^5.0.0",
    "sass": "^1.77.8",
    "sass-loader": "^12.1.0"
  }
}

webpack.mix.js:

cons mix = require('laravel-mix');
require('laravel-mix-svg-sprite');
mix
    .sass('src/scss/style.scss','output/css')
    .svgSprite(
        'src/icons', // The directory containing your SVG files
        'output/sprite.svg' // The output path for the sprite
);
npm mix

In the output/css folder I see my style.css file

Wher's my svg sprites? What is a simple config for getting sprites?

JaZo commented 1 month ago

Although we don't use it ourselves anymore, it should still work. What is the content of your Sass file? This plugin only adds a loader to the Webpack configuration, it doesn't glob your icons directory and include every file it finds. You need to require the icons from within your code (JS, CSS, etc.) just like other modules, to have them added to the sprite!