# svelte-loader **Repository Path**: mirrors_jquense/svelte-loader ## Basic Information - **Project Name**: svelte-loader - **Description**: Webpack loader for svelte components. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-02 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # svelte-loader [![Build Status](https://travis-ci.org/sveltejs/svelte-loader.svg?branch=master)](https://travis-ci.org/sveltejs/svelte-loader) A [webpack](https://webpack.js.org) loader for [svelte](https://svelte.technology). ## Install ``` npm install --save svelte svelte-loader ``` ## Usage Configure inside your `webpack.config.js`: ```javascript ... resolve: { // see below for an explanation alias: { svelte: path.resolve('node_modules', 'svelte') }, extensions: ['.mjs', '.js', '.svelte'], mainFields: ['svelte', 'browser', 'module', 'main'] }, module: { rules: [ ... { test: /\.(html|svelte)$/, exclude: /node_modules/, use: 'svelte-loader' } ... ] } ... ``` Check out the [example project](https://github.com/sveltejs/template-webpack). ### resolve.alias The [`resolve.alias`](https://webpack.js.org/configuration/resolve/#resolvealias) option is used to make sure that only one copy of the Svelte runtime is bundled in the app, even if you are `npm link`ing in dependencies with their own copy of the `svelte` package. Having multiple copies of the internal scheduler in an app, besides being inefficient, can also cause various problems. ### resolve.mainFields Webpack's [`resolve.mainFields`](https://webpack.js.org/configuration/resolve/#resolve-mainfields) option determines which fields in package.json are used to resolve identifiers. If you're using Svelte components installed from npm, you should specify this option so that your app can use the original component source code, rather than consuming the already-compiled version (which is less efficient). ### Extracting CSS If your Svelte components contain `