Skip to content

firefish5000/svelte-trim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svelteTrim

Trims unwanted whitespace out from between <dom nodes="">, <Components />, {tags}, and {#blocks} of svelte files.

Usage:

Place as the last preprocessor in your svelte.config.js's preprocess field. If you us any other preprocessors, wrap them in a call to asMarkupPreprocessor.

Warning! Currently, we must be run on valid/pure svelte files! This means any other preprocessors you use must run before us. Due to how svelte.preprocess works, just placiing them before us will not be enough. You must additionaly wrap them in svelte-as-markup-preprocessor. See their readme for an explanation of why this is necessary.

// svelte.config.js
const {asMarkupPreprocessor} = require('svelte-as-markup-preprocessor')
const sveltePreprocess = require('svelte-preprocess')
const {mdsvex} = require('mdsvex')
const {svelteTrim} = require('svelte-trim')
module.exports = {
  preprocess: [
    asMarkupPreprocessor([
      sveltePreprocess(),
      mdsvex()
    ]),
    svelteTrim({
      removalMethod: 'trim'
      multiline: true,
      inline: false
    })
  ]
}

Call Signature

svelteTrim(passedOptions?: WhitespaceStripperOptions): PreprocessorGroup

Parameters:

Most common options included below. Full list available here.

Option Name Type Default
removalMethod 'trim'|'comment' 'trim'
inline boolean false
multiline boolean true
componentSiblings boolean true
elementSiblings boolean true
mustacheBlockSiblings boolean true
mustacheDirectiveSiblings boolean true
mustacheTextSiblings boolean false
ignoreElements Array<ElementType> ['pre','code','style','script']

About

Strips whitespace from svelte files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published