Does anyone know if we could provision js files to SharePoint site using SharePoint Framework ?

I read on Microsoft Dev that it could provision SharePoint data (sitecolumns, contenttypes, lists) but nothing about the document files (js, css is my concern for now).


  • Yes of course :) youtube.com/watch?v=W_ABwoHrEls&t=594s
    – Goshky
    Commented Sep 26, 2017 at 11:55
  • @Goshky I couldn't find any thing like that in the vids. All they said are about provision lists, etc...And they are using SPFx v1.3
    – Thi Vo
    Commented Sep 27, 2017 at 3:08
  • Why would you want to provision separate .js and .css files rather than including them in the generated bundle? Commented Sep 28, 2017 at 16:56
  • @WaldekMastykarz-MVP: My solution needs to work on both Classic and Modern UI. So I was trying to inject the js and css into Custom Actions in Classic UI. And I need to know the link to send to the ScriptLink. Hence the link need to be static.
    – Thi Vo
    Commented Oct 4, 2017 at 2:40
  • @Thi: Classic and modern UI are based on two different sets of APIs so not sure you will be able to reuse as much of your code base as you'd need to make this approach worth the effort. Commented Oct 4, 2017 at 6:08

1 Answer 1


I found the answer. I have to include it in the elements.xml as normally.

<Module Name="Files" Url="SiteAssets">
    <File Path="test.js" Url="test.js" Type="GhostableInLibrary" ReplaceContent="TRUE" >

Then reference the file in package-solution.json:

"assets": {        
    "elementManifests": [

Finally, I have to extract the package using WinRar or something and include the js extension in the [Content_Types].xml (If the extension has already been here then you dont have to do this step. Right now it has .jpg, .pnp, .gif, .xml, .rels, .webpart, .htm, .aspx, .resx)

<Default Extension="js" ContentType="application/wsp"></Default>
<Default Extension="css" ContentType="text/stylesheet"></Default>

Trying to figure how to include js extension by default using gulp package-solution. Really hope MS will do this later instead of leaving out the .js (and .css) files.

Reference for [Content_Types].xml structure: https://docs.microsoft.com/en-us/visualstudio/extensibility/the-structure-of-the-content-types-dot-xml-file?view=vs-2022

  • Just stumbled across the issue that you have to unpack the solution and add the content type. Do you have any idea how to do that during the packaging/bundling process?
    – Andreas
    Commented Oct 22, 2018 at 14:05
  • Sorry I only know how to do that manually, if you want to do that during bundle you have to research on gulp.
    – Thi Vo
    Commented Oct 23, 2018 at 15:53
  • do you know whats the ContentType for CSS? Commented Dec 15, 2021 at 20:09
  • 1
    @MurtuzaHusain: My answer was in 2017 and it has changed for now I think. At least js files are included in the Content_Types.xml on latest SPFx. But for reference you can check them here: docs.microsoft.com/en-us/visualstudio/extensibility/…. For CSS I think it's just MIME Type so probably text/css
    – Thi Vo
    Commented Dec 17, 2021 at 7:37
  • I just checked , text/css did not work, but text/stylesheet did work. Hope this helps somebody Commented Dec 17, 2021 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.