enuchi / React-Google-Apps-Script

This is your boilerplate project for developing React apps inside Google Sheets, Docs, Forms and Slides projects. It's perfect for personal projects and for publishing complex add-ons in the Google Workspace Marketplace.
MIT License
1.33k stars 178 forks source link

ReferenceError: antd is not defined #196

Closed codeatrajan closed 1 year ago

codeatrajan commented 1 year ago

Hi I have made a fresh clone of the repo and Installed the packages and Its working fine,

And i have tried to add a new package npm i antd

and updated the webpack.config.js for adding CDN

case 'antd': return { name: packageName, var: 'antd', version: packageVersion, url: https://unpkg.com/antd@${packageVersion}/dist/antd${packageSuffix}, }; But after deploying getting ReferenceError: antd is not defined this is the CDN Link https://unpkg.com/antd@5.7.3/dist/antd.min.js

enuchi commented 1 year ago

Can you research if antd has a UMD build?

codeatrajan commented 1 year ago

Yes, antd has UMD build https://ant.design/docs/react/contributing#build

https://unpkg.com/browse/antd@5.7.3/dist/

enuchi commented 1 year ago

See here: https://ant.design/docs/react/introduce#import-in-browser and the note there:

Note: You should import react、react-dom、dayjs before using antd.js.

I got this to work by adding the following to the index.html template in the <head> tag:

<script src="https://unpkg.com/dayjs@1.11.9/dayjs.min.js"></script>

and using the antd config in webpack.config.js that you shared above.

enuchi commented 1 year ago

See the basic changes needed here: https://github.com/enuchi/React-Google-Apps-Script/commit/0d074a087951871ac276659dc9e5e23d1a436c1b

codeatrajan commented 1 year ago

Yes, Now I can able add it after adding dayjs.

Thanks for providing this great project and support.

enuchi commented 1 year ago

Happy to help