• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Improve your SharePoint Framework development flow by speeding up the "serve" command 🚀

🚀 SPFx Fast Serve Tool

npm version

A command line utility, which modifies your SharePoint Framework solution, so that it runs continuous serve command 10-15x times faster, than the regular gulp serve.

Curious how it works under the hood? Read my blog post here.

IMPORTANT

spfx-fast-serve version 4.x (current) supports SPFx starting from version 1.17. Read more here

How to use

  1. npm install spfx-fast-serve -g
  2. Open a command line in a folder with your SharePoint Framework solution you want to speed up.
  3. Run spfx-fast-serve and follow instructions. In most cases you shouldn't do anything specific and the CLI "just works".
  4. Run npm install
  5. Run npm run serve and enjoy the incredible speed of serve command!

fast-serve CLI

The spfx-fast-serve command simply adds necessary things to run your serve faster. Among them, it installs spfx-fast-serve-helpers NodeJS package. The package contains the fast-serve CLI, which does all the magic "serve" things. Each CLI option could be provided as a command line parameter or could be stored inside the fast-serve configuration file under <your SPfx project>/fast-serve/config.json. The config file is not created by default, but you could create it using fast-serve CLI commands.

fast-serve CLI options

option type defaults description
port integer 4321 HTTP port to use to serve the bundles
memory integer 8192 Memory limits for the dev server in MB
locale string - Local code when running in a multi-language scenario, i.e. --locale=nl-nl
config string - Serve configuration to run on a startup. It works exactly the same as the OOB gulp serve --config=[config-name]
openUrl string - URL to open on a startup. If empty, no URL will be opened. Supports SPFx {tenantDomain} placeholder
loggingLevel enum normal Logging level, 'minimal' notifies about errors and new builds only, 'normal' adds bundle information, 'detailed' displays maximum information about each bundle
fullScreenErrors boolean true Whether to show errors with a full-screen overlay on UI or not (only in console)
isLibraryComponent boolean false Should be true, when running inside library component project type
eslint boolean true When true, adds eslint-webpack-plugin to lint your code with lintDirtyModulesOnly:true option for performance
hotRefresh boolean false Enables webpack's Hot Module Replacement (HMR). This feature is considered as experimental, meaning that you can try and use it if it works well for your project. Read more here
reactProfiling boolean false When true, enables react profiling mode through React Chrome extension. By default profiling doesn't work in SPFx solutions (even in dev mode).
containers boolean false Explicitly enables containerized environment support. By default, fast-serve automatically detects a containerized environment (like Docker) and applies needed configuration. But if it doesn't work for you, you can explicitly disable or enable support for containers using this option.
debug boolean false Enables debug mode for fast-serve

Here is a sample configuration:

{
  "$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.v2.schema.json",
  "serve": {
    "config": "my-config",
    "fullScreenErrors": false,
    "debug": true
  }
}

If you call fast-serve with the above configuration file, it will be the equivalent of calling the CLI with the below parameters (taken from file):

fast-serve --config=my-config --fullScreenErrors=false --debug

If you have the same option provided in both file and CLI, the CLI option will take the precedence.

fast-serve commands

fast-serve CLI supports below commands:

  • fast-serve webpack extend - adds fast-serve webpack extensibility file to the project. Read more on webpack extensibility here
  • fast-serve config add - adds fast-serve configuration file to the project

Migration between SPFx versions

The migration is as easy as just changing the version of spfx-fast-serve-helpers in your package.json to match the corresponding SPFx minor version (do not change the patch version).

For example, if your project is based on SPFx 1.17, then you have the below dependency:

"spfx-fast-serve-helpers": "~1.17.0"

To migrate fast-serve to SPFx 1.18 you just need to change it like this (patch version should be 0, we change only minor version):

"spfx-fast-serve-helpers": "~1.18.0"

Reinstall all dependencies and that's it!

Webpack extensibility

If you use custom webpack loaders or other webpack modifications via build.configureWebpack.mergeConfig feature, you should manually apply them to webpack.extend.js file created by the CLI to make everything work. Apply only those webpack modifications, which work on a regular gulp serve command, since spfx-fast-serve works only in development mode.

By default, you don't have webpack.extend.js file. Run

npx fast-serve webpack extend

to create it. In this file you can put your own logic for webpack, it will not be overwritten by the subsequent spfx-fast-serve calls.

You can either provide custom webpackConfig object, which will be merged using webpack-merge module, or use transformConfig to even better control over configuration.

Check out this sample to see how it works. The sample configures custom path aliases for SPFx.

Which SharePoint Framework versions are supported

The latest [email protected] version supports SPFx 1.17 and onwards.

Version 3.x supports SPFx 1.4.1 and above. If you need to run the tool for SPFx < 1.17, you could use npx tool for npm or dlx for pnpm:

npx -p [email protected] -- spfx-fast-serve
pnpm [email protected] dlx spfx-fast-serve

You could also use 3.x branch to see the documentation for 3.x version.

SharePoint 2016 is NOT supported.

How it works

The tool adds necessary files to run your own webpack based build with webpack dev server. Technically it's a custom webpack build, which produces the same output files as SharePoint Framework build pipeline, but does it a lot faster, because of a number of improvements:

  • all compilation are done in a memory with webpack, no additional "copy", "prepare", "typescript", "whatever" tasks.
  • incremental TypeScript compilation when a file is being changed. It means only necessary files are compiled, not everything.
  • asynchronous type checking and linting.

Also

  • live reloading for hosted workbench, MS Teams host, mobile devices (with ngrok serve)
  • debugging from VSCode with Chrome Debugger extension
  • supports WSL2
  • Hot Module Replacement (HMR) - experimental support
  • doesn't mess up your default SPFx build. If you have troubles, simply switch back to regular gulp serve
  • supports all major node package managers

NGROK serve plugin

spfx-fast-serve supports ngrok as a proxy between webpack dev server and SharePoint. This is possible through the NgrokServePlugin webpack plugin. This option allows you to test your SPFx solution live on mobile devices in development mode.

Read more here on how you can configure it.

Library components

Please use this guide to configure spfx-fast-serve with library components.

Privacy policy

spfx-fast-serve tracks every run using "fast serve" option. The "run" data includes time, when you run npm run serve and irreversible hash of computer name (to track unique computers). It does NOT collect nor store any personal, computer, network or project information. "Run" data needed to analyze, how many runs using "fast serve" scenario we have per day\month\year and what is the trend. Based on the data I can make a decision whether to further invest time into this project or not.

Having troubles? Please try to find the answer under FAQs or raise an issue

More Repositories

1

node-sp-auth

Unattended SharePoint http authentication with nodejs
TypeScript
137
star
2

sp-rest-explorer

Source code for SharePoint REST API Metadata Explorer
TypeScript
89
star
3

spsave

Save files in SharePoint using node.js easily
TypeScript
86
star
4

gulp-spsave

Gulp plugin for saving files inside SharePoint
JavaScript
52
star
5

sp-request

Simplified SharePoint HTTP client
TypeScript
52
star
6

modern-sharepoint-developer-roadmap

Roadmap for modern SharePoint developer
9
star
7

node-pnp-js

PnP-JS-Core (sp-pnp-js) with Node.js made easy
TypeScript
9
star
8

vscode-sp-typed-item

Generates TypeScript interfaces based on SharePoint data.
TypeScript
9
star
9

spfx-fast-serve-helpers

Contains helper classes and functions for spfx-fast-serve tool.
TypeScript
8
star
10

SPListRepository.js

Repository pattern implementation for convenient list data access through the SharePoint JavaScript client object model.
JavaScript
7
star
11

node-pnpjs-sample

This repository contains sample using pnp-js library with nodejs
TypeScript
7
star
12

sphooks

Cross-platform CLI for managing SharePoint list web hooks
JavaScript
4
star
13

spfx-fix-node10

Quick fix to run SPFx 1.7 on node10.x
JavaScript
4
star
14

expressjs-sp-addin

SharePoint add-in with Express.js and PnP-JS-Core
TypeScript
4
star
15

SharePoint-AspNet-Authentication

SharePoint add-in authentication middleware for Asp.Net MVC (both Asp.Net Core and Asp.Net MVC 5 via Owin)
C#
4
star
16

pnp-dev-resources

PnP developer resources
4
star
17

SharePoint-RER-with-Azure-Function-TypeScript

Sample on implementing SharePoint Remote Event Receiver with Azure Function written in TypeScript
TypeScript
4
star
18

react-simple-hook-store

Simple React hook based state management
TypeScript
3
star
19

spfx-check-locale

Check the consistency of your localization files inside SharePoint Framework projects.
TypeScript
3
star
20

passport-sharepoint-addin

Passport.js authentication middleware for SharePoint add-in
TypeScript
3
star
21

node-spoauth

Authenticate in SharePoint Online with node.js
JavaScript
2
star
22

time-zone-manager

TimeZoneManager is a sample web application built with ASP.NET Core and Vue.js
C#
2
star
23

sp-webpack-dev-proxy

Sample webpack http dev proxy setup which routes requests to SharePoint REST API
TypeScript
2
star
24

spfx-vue-sfc-one-file

Sample on implementing SPFx web part with Vue's single file component approach when all .vue artefacts (code, template, styles) are in a single .vue file
HTML
2
star
25

spfx-vue-hello-world

Hello World SharePoint Framework client web part with Vue.js
CSS
2
star
26

espc17-demos

Source code for demos at ESPC'17 "Building SharePoint Add-ins with PnP-JS-Core on a Client AND Server Side"
TypeScript
2
star
27

PnPjs-your-friend-demos

Sources for demos from "PnPjs - Your New SharePoint and Office 365 Development Friend" presentation
TypeScript
2
star
28

vsts-pnp-powershell

PnP-PowerShell VSTS build step
TypeScript
2
star
29

vue-ts-sfc-webpack-hmr

Sample starter for VueJS+TypeScript+SFC+HMR
JavaScript
1
star
30

vue-pnpjs

Vue.js and PnP.js integration plugin
TypeScript
1
star
31

gulp-jasmine-inject

Gulp plugin for injecting and runing jasmine tests in any working web site
JavaScript
1
star
32

StackAnalysis

Source code for program used to grab data for SP SE analysis
C#
1
star
33

pnpm-fast-serve-ws-test

JavaScript
1
star
34

sp-typed-item

Node.js module, CLI and VSCode extension for generating TypeScript interfaces based on SharePoint data.
TypeScript
1
star
35

SPAsyncScript

SPAsyncScript lets you implement SharePoint Script On Demand (SOD) easily
JavaScript
1
star