Skip to content

esarbanis/svelte-preprocess-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svelte-preprocess-loader

Build Status

A webpack loader for svelte components preprocessing.

Usage

Configure inside your webpack.config.js:

  ...
  module: {
    rules: [
      ...
      {
        test: /\.(html|svelte)$/,
        exclude: /node_modules/,
        use: {
          loader: 'svelte-preprocess-loader',
          options: {
            markup: ({ content }) => {
                // `content` is the entire component string
                return { code: '...', map: {...} };
            },
        
            style: ({ content, attributes }) => {
                // `content` is what's inside the <style> element, if present
                // `attributes` is a map of attributes on the element
                if (attributes.type !== 'text/scss') return;
                return { code: '...', map: {...} };
            },
        
            script: ({ content, attributes }) => {
                // `content` is what's inside the <script> element, if present
                // `attributes` is a map of attributes on the element
                if (attributes.type !== 'text/coffeescript') return;
                return { code: '...', map: {...} };
            }
          }
        }
      }
      ...
    ]
  }
  ...

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published