- A GitHub account https://github.com
- A way to quickly clone GitHub repos (command line, SourceTree, GitHub Desktop, etc.)
- git installers: https://git-scm.com/downloads
- NodeJS (6.9.2 or higher): https://nodejs.org
- Netlify Account: https://app.netlify.com/
- Netlify Docs: https://www.netlify.com/docs/
-
Login to GitHub and create a new repository for your project
-
Login to Netlify (preferably through GitHub) https://app.netlify.com/
-
Open your command like tool of choice (terminal, git bash etc.)
-
Clone the repo you created onto your computer
git clone <your-github-project-url>
-
Switch to your project directory
cd <your-github-project-name>
-
Run
npm init
to setup your project -
Add necessary dependencies to project
"dependencies": { "bootstrap-scss": "^4.3.1", "dotenv": "^7.0.0", "querystring": "^0.2.0" }, "devDependencies": { "copy-webpack-plugin": "^5.0.2", "css-loader": "^2.1.1", "elm-webpack-loader": "^5.0.0", "file-loader": "^3.0.1", "netlify-lambda": "^1.4.7", "node-sass": "^4.11.0", "raw-loader": "^2.0.0", "sass-loader": "^7.1.0", "style-loader": "^0.23.1", "uglifyjs-webpack-plugin": "^2.1.2", "webpack": "^4.30.0", "webpack-cli": "^3.3.0", "webpack-dev-server": "^3.3.1" }
-
Run
npm install
-
Navigate your browser to the Netlify site, and go to "Sites", then click the "New site from Git" button
-
In the "Continuous Deployment" section, click the "GitHub" button
-
Click the "Configure the Netlify app on GitHub" link
-
Walk through the steps for connecting to GitHub
-
Select the new repository you created in step #1
-
Select a "Branch to Deploy"
-
For the "Build Command", enter
npm run deploy
-
For the "Publish Directory:, enter
dist
-
Click "Deploy Site"
- This deploy will fail, we haven't setup a deploy script, yet.
-
Next, we'll setup the npm commands for our project
-
Install the Netlify CLI
npm install -g netlify-cli
-
Install the netlify-lambda on your computer
npm install -g netlify-lambda
-
Add the following to your
package.json
file in thescripts
section"deploy": "npm run lambda:build && webpack --mode production", "watch": "webpack --mode production --watch", "elm": "elm", "lambda:build": "netlify-lambda build ./src/lambda"
-
Run
netlify init
-
Choose "Link this directory to an existing site"
-
Select "Use current git remote url
<you-github-site-url>
" -
Open the
.netlify/state.json
file and copy thesiteId
on to your clipboard -
Create your Netlify settings file, name it
netlify.toml
with the following contents:[Settings] ID = "<your-netlfiy-site-id>" [build] functions = "./functions" publish = "dist"
-
Create a new file named
webpack.config.js
and add the contents of webpack.config.js to it -
Run
elm init
and select yes to create your Elm configuration file -
Create a new
elm
directory in yoursrc
directorymkdir -p src/elm
-
Create a new file
src/elm/Main.elm
and copy the contents of this file into it src/elm/Main.elm -
Create a file
src/index.html
and copy the contents of this file into it src/index.html -
Create a new
js
directory in yoursrc
directorymkdir -p src/js
-
Create a file
src/js/app.js
and copy the contents of this file into it src/js/app.js -
Open a new terminal window/tab and run the following command
npm run watch
-
Open a new terminal window/tab and run the following command
netlify dev --live
-
Click on the link displayed in the terminal you executed
netlify dev --live
in to open a dev version of the site -
Add the following to you
.gitignore
file:# elm-package generated files elm-stuff # elm-repl generated files repl-temp-* node_modules functions dist .env
-
To deploy, you have two options
- Commit and push all of your changes to the
master
branch of your repo - Run
netlify deploy --prod
- Commit and push all of your changes to the