diff --git a/CHANGELOG.md b/CHANGELOG.md index 188d4365..1f43901e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ -# svelte-loader changelog +# @non25/svelte-loader changelog -## 3.1.2 (Unreleased) +## 3.1.3 + +* Readme overhaul +* Remove outdated examples + +## 3.1.2 * Update to latest `svelte-hmr` package fixing Webpack 4 support * Fix sourcemap breakpoints ([#183](https://github.com/sveltejs/svelte-loader/pull/183)) diff --git a/LICENSE.md b/LICENSE.md index ea0fb28b..8e931c38 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2016-21 [these people](https://github.com/sveltejs/svelte-loader/graphs/contributors) +Copyright (c) 2016-21 [these people](https://github.com/non25/svelte-loader/graphs/contributors) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 7b9fe51a..da35b21b 100644 --- a/README.md +++ b/README.md @@ -1,269 +1,183 @@ -# svelte-loader +# @non25/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). +Fork of a [webpack](https://webpack.js.org) loader for [svelte](https://svelte.dev) with bugs fixed. +Webpack 4 & 5 are supported. ## Install +On the existing project, make sure to have following packages: + ``` -npm install --save svelte svelte-loader +npm install -D svelte @non25/svelte-loader svelte-preprocess postcss postcss-import postcss-load-config ``` - ## Usage -Configure inside your `webpack.config.js`: +Here's full-featured configuration with hot module replacement: ```javascript +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const sveltePreprocess = require('svelte-preprocess'); +const mode = process.env.NODE_ENV || 'development'; +const prod = mode === 'production'; ... resolve: { - // see below for an explanation + // include only one version of svelte runtime alias: { svelte: path.resolve('node_modules', 'svelte') }, + + // import .svelte files without extension extensions: ['.mjs', '.js', '.svelte'], + + // use sources of third-party svelte packages mainFields: ['svelte', 'browser', 'module', 'main'] }, module: { rules: [ ... { - test: /\.(html|svelte)$/, - use: 'svelte-loader' - }, - { - // required to prevent errors from Svelte on Webpack 5+, omit on Webpack 4 - test: /node_modules\/svelte\/.*\.mjs$/, - resolve: { - fullySpecified: false - } - } - ... - ] - } - ... -``` - -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 + test: /\.svelte$/, + use: { + loader: '@non25/svelte-loader', + options: { + compilerOptions: { + // required by hot module replacement (HMR) + dev: !prod, + }, -If your Svelte components contain `