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

[email protected] contains 115 MiB of vue-cli #144

Open
simon04 opened this issue Dec 10, 2020 · 8 comments
Open

[email protected] contains 115 MiB of vue-cli #144

simon04 opened this issue Dec 10, 2020 · 8 comments

Comments

@simon04
Copy link

simon04 commented Dec 10, 2020

The npm package [email protected] contains 115 MiB of vue-cli – https://unpkg.com/browse/[email protected]/

Please re-package in a clean environment.

@Raademar
Copy link

Raademar commented Feb 8, 2021

Is this being looked into?

@simon04
Copy link
Author

simon04 commented Feb 9, 2021

I gave up waiting and replaced vue-svg-loader with a minimalistic loader stored in the project itself:

// vue-svg-loader.js
module.exports = function VueSvgLoader(svg) {
  this.cacheable();
  return `<template>${svg}</template>`;
};

// vue.config.js
module.exports = {
  chainWebpack: (config) => {
    config.module.rule("svg").uses.clear();
    config.module
      .rule("svg")
      .use("vue-loader")
      .loader("vue-loader")
      .end()
      .use("./vue-svg-loader")
      .loader("./vue-svg-loader");
  },
};

@Raademar
Copy link

This solution worked fine for me

@pmrotule
Copy link

I gave up waiting and replaced vue-svg-loader with a minimalistic loader stored in the project itself:

// vue-svg-loader.js
module.exports = function VueSvgLoader(svg) {
  this.cacheable();
  return `<template>${svg}</template>`;
};

// vue.config.js
module.exports = {
  chainWebpack: (config) => {
    config.module.rule("svg").uses.clear();
    config.module
      .rule("svg")
      .use("vue-loader")
      .loader("vue-loader")
      .end()
      .use("./vue-svg-loader")
      .loader("./vue-svg-loader");
  },
};

@simon04 You don't seem to optimize your svg code with svgo like vue-svg-loader would do.

@simon04
Copy link
Author

simon04 commented Apr 27, 2021

@pmrotule, you're right. My use-case was to load bootstrap-icons. Thus, using svgo seemed unnecessary.

@vpillinger
Copy link

vpillinger commented Nov 10, 2021

Here is code with svgo 2.2.

// vue-svg-loader.js
const { optimize } = require('svgo');

module.exports = async function (svg) {
	this.cacheable();

	const svgo = new SVGO(svgoConfig);

	({ data: svg } = await svgo.optimize(svg, {
		path: this.resourcePath,
	}));

	return `<template>${svg}</template>`;
};

@jzymx50
Copy link

jzymx50 commented Nov 27, 2021

As an alternative, if you only use vue2, you can switch to version 0.17-beta.0.

@rdhainaut
Copy link

Here is code with svgo 2.2.

// vue-svg-loader.js
const { optimize } = require('svgo');

module.exports = async function (svg) {
	this.cacheable();

	const svgo = new SVGO(svgoConfig);

	({ data: svg } = await svgo.optimize(svg, {
		path: this.resourcePath,
	}));

	return `<template>${svg}</template>`;
};

Unfortunately it seems doesn't work with svgo 3 :(

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

6 participants