This is startup template that I found myself use so often and it take sometime to setup so I preconfigured it to be ready to work with.
- First I removed
milligramCSS Framework that is used by default in Phoenix by just deletingphoenix.cssfile from/assets/css/folder. - Added
BulmaCSS Framework usingyarn add bulma --devand changed/assets/app.css->/assets/app.scssand added to it:@import "~bulma/bulma"to add support for Bulma, you can write the full path../node_modules/bulma/bulmaif you faced issues in recognizing it.@import "./custom"for my custom styles, refers to/assets/_custom.scssfile.
- Added
TailwindcssCSS utility framework to have more control on my styling, for information about how to install it and configure it please read this quick tutorial.
- Support Sass using
DartSassandsass-loader. - Configure
sass-loaderoptions:{implementation: require("sass")}so it will usesassinstead of the default onenode-sassand will stop complaining. - Added
Elmwhich was installed globally on my system, but you can install it usingyarnornpmto your dependencies - Support Elm using
elm-webpack-loader - While you are in
/assetsfolder path, run in terminalelm initto initialize elm app which will addelm.jsonandsrcfolder for you under/assetsfolder directly. - In
/assets/js/app.jsfile you need to write these lines of code:import { Elm } from "../src/Main.elm" var app = Elm.Main.init({ node: document.getElementById('elm-main') });
- I replaced everything in
/lib/YOUR_APP_WEB/templates/page/index.html.eexfile with<div id="elm-main"></div>as here my elm output will show up. - I removed most of boilerplate code that comes in
app.html.eexfile. I added alsoFontAwesome 5.9.0 - Sometimes I face issues when installing
elm-webpack-loaderdue to node version, as I always have latest version of it so if you have issues due to node version then add.nvmrcfile inside/assetsfolder and in it write12.13.0which is latest LTS version of node at the time of writing this, if you want to configurenvmor install it on your system check this if you useoh-my-zshor this fornvmitself as a Node Version Manager, UPDATE: no issues with new versions of node as I have now version 13.3.0 and it works fine.
- Add
GraphQLfor Phoenix is very straight forward, check pleaseAbsinthefor installation. - To make Elm talks
GraphQL, we will installelm-graphqlpackage usingelm installcommand in Terminal while you are in/assetsfolder as your elm app installed there or if you separate it somewhere else then you need to install that package where your elm app exsits.
- Modified
router.exfile with the/graphqland/graphiqlroutes. - Added some dummy folders and files for schema file, schema types, resolvers files.
- Add folders and files for schema and resolvers.
- Add User Authentication and Authorization.
- Add Session support.
- Add GraphQL Schema and Resolvers.
- Add Blog Posts and Comments schemas.
- Implement GraphQL to create, delete Posts and Comments.
- Implement Elm-GraphQL and connect to our backend.
- Install dependencies with
mix deps.get - Create and migrate your database with
mix ecto.setup - Install Node.js dependencies with
cd assets && yarn install - Start Phoenix endpoint with
mix phx.server
Now you can visit localhost:4000 from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: http://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Mailing list: http://groups.google.com/group/phoenix-talk
- Source: https://github.com/phoenixframework/phoenix