question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable runtime configuration completely?

See original GitHub issue

Do you want to request a feature, report a bug or ask a question? Ask a question

What is the current behavior? SVGs get extracted and injected into my template, but there is ~30kb of additional code in my bundle: image

What is the expected behavior? I don’t import any icons in code, they are exclusively used in the templates. It’s unused code I’d like to avoid shipping.

If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code. My relevant config:

const iconsContext = resolve(__dirname, '../src/icons');
module.exports = {
   module: {
      rules: [
         { test: /\.svg$/, use: [
            { loader: 'svg-sprite-loader', options: { extract: true } },
            { loader: 'svgo-loader', options: { plugins: [ { removeDoctype: true }, { removeXMLProcInst: true }, { removeComments: true }, { removeMetadata: true }, { removeEditorsNSData: true }, { cleanupAttrs: true }, { convertStyleToAttrs: true }, { removeRasterImages: true }, { cleanupNumericValues: true }, { convertColors: true }, { removeUnknownsAndDefaults: true }, { removeNonInheritableGroupAttrs: true }, { removeUselessStrokeAndFill: true }, { removeViewBox: true }, { cleanupEnableBackground: true }, { removeHiddenElems: true }, { removeEmptyText: true }, { convertShapeToPath: true }, { moveElemsAttrsToGroup: true }, { moveGroupAttrsToElems: true }, { collapseGroups: true }, { convertPathData: true }, { convertTransform: true }, { removeEmptyAttrs: true }, { removeEmptyContainers: true }, { mergePaths: true }, { cleanupIDs: true }, { removeUnusedNS: true }, { transformsWithOnePath: false }, { sortAttrs: true }, { removeTitle: true } ] } }
         ], include: iconsContext },
      ],
      plugins: [
         new SpriteLoaderPlugin({ plainSprite: true })
      ]
   }
}

If you want to reproduce, here’s my repo (it’s not minimal though):

git clone https://github.com/vpdb/website.git vpdb-website
cd vpdb-website && npm install
npm run build:analyze

Please tell us about your environment:

  • Node.js version: v8.9.1
  • webpack version: 4.4.1
  • svg-sprite-loader version: 3.7.3
  • OS type & version: Windows 10 x64

I’ve tried setting runtimeGenerator to null, but that obviously didn’t work. Maybe this is achievable in any other way, otherwise I would welcome an option to only extract without bloating the JavaScript bundle.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kisenkacommented, Apr 3, 2018

You’re right, extract runtime is not optimal, because it contains symbol id, viewBox etc. As quick workaround you can write own runtime generator which returns only path to symbol:

extract-runtime-generator.js

module.exports = function runtimeGenerator({ symbol }) {
  return `export default __webpack_public_path__ + ${JSON.stringify(symbol.request.file)}`;
};

And setup it in loader config:

{
	loader: 'svg-sprite-loader', options: {
		runtimeGenerator: require.resolve('runtime-generator-path'),
		extract: true
	}
}
0reactions
freezycommented, Aug 9, 2019

Thanks, I’ll try that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a runtime configuration to disable diagnostics server
Currently the diagnostics server is always created and there is no way of configuring the runtime to not do this. We should add...
Read more >
Enable and Disable Endpoints at Runtime With Spring Boot
In this tutorial, we'll learn to enable and disable endpoints at runtime in a Spring Boot application using a few popular libraries, ...
Read more >
Runtime Settings Schema - .NET Framework - Microsoft Learn
Runtime settings are used by the common language runtime to configure applications that target .NET Framework. This article shows the schema ...
Read more >
Runtime Configuration - Manual - PHP
The behaviour of these functions is affected by settings in php.ini . ... disable : Completely disabled, cannot be enabled at runtime. off...
Read more >
Disable all Database related auto configuration in Spring Boot
They were enough for me, but im not sure if its all to completely disable database related libraries. Check the list below to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found