I’ve modified my SCSS Breakpoints Shell Script a tiny bit to now add @import <<viewport size>> for each of the module viewport breakpoints to my main theme.scss file. I’ve set this up to work with my own setup, but if it’s useful to anyone else I’ve added it to github.
Installing Node.js also installs a copy of npm. According to npm the copy of npm that Node.js installs is often out of date so I followed their instructions to install.
npm install npm@latest -g
Permissions Error
Note: If like me you get a permissions error just add sudo to the start. Only ever do this if you know what you are installing however!
Once I had finished that I went through the webpack basic tutorial in Terminal to get an idea what it was for.
The XD Plugin React tutorial I was following also uses Yarn so installed that as well. Yarn uses homebrew to install which I already have installed (it’s very useful).
The basic steps when creating a project that will be using a package library seems to be:
Create a Project folder (mkdir)
Navigate to above folder (cd)
Create a package.json file (init) without asking questions ( -y )
But when you finish that you end up with the main.js file located inside your development folder. You won’t want to copy the entire thing into Adobe XD because you don’t need all of it.
Adding a Distribution Folder
We want to end up with this instead:
The example-plugin folder in the dist (distribution) folder is the one that gets copied to Adobe XD.
This creates the dist folder Then Creates the example-plugin folder inside the dist folder Moves the manifest.json (a file which Adobe XD needs) to dist/example-plugin Deletes the currently compiled main.js
Then we need to change a couple of things. Open package.json and change the following line :
"main": "dist/example-plugin/main.js",
Open webpack.config.js and change the following line in the output section:
filename: "dist/example-plugin/main.js",
This is what it should look like.
If I run yarn now this will create the main.js in the desired location