In the above document we have referenced the external Jquery UI css. Can not we use CSS installed as a part of node module Jquery-Ui
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Sure... you can but then the CSS is included in the bundle with your component. Referencing external CDN hosted files is a better & more performant approach.
Thanks Andrew,
I have couple of more queries.
Closing issue as "answered". If you encounter similar issue(s), please open up a NEW issue. Thank you.
When we install external library as package and then include those in External under config.json. (same like above). Then how they are referenced in the webpart solution. For external libraries they are downloaded bu hitting the URL. Does files under node modules also compiled while packaging the solution.
Two things:
exernals collection is used by webpack primarily. Webpack sees that and says "when I see an import statement, I ignore it and don't suck that library into the bundle". externals is added to this list. See for yourself... don't put something in externals and run gulp bundle. Look at the JSON file in the ./dist folder. Now, add something to externals that you are using and repeat. Notice the difference.Even if we mark them external, while importing in our webpart file , they are importing from the Node folders only. So the name specified in extenal can be anything. Is it correct.?
No... see last answer. The name is what webpack is using as it's list of "don't suck these libraries into the bundle"
Is there a difference between loading script from spcomponentloader method and using external files in config.json.?
Yup, stuff defined in config.json is added to the manifest which is used to load all dependencies before the component's bundle is loaded on the page. The SPComponentLoader is a programmatic way to load things at runtime. If your component ALWAYS needs it to run, set it as a dependency. If it's conditional, then SPComponentLoader is an option.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues
Most helpful comment
Sure... you can but then the CSS is included in the bundle with your component. Referencing external CDN hosted files is a better & more performant approach.