npm init
- sometimes a weird error is thrown (cannot find
/.options
), easy fix is to delete node_modules directory and runnpm install
- contents for webpack.config.js (see additional file)
- root for webpack.config.js
mkdir src
touch src/index.js
, output:mkdir public
touch public/index.html
index.html
should have basic html/css + div (idroot
) to mount app to, and scriptsrc=/app.js
- install dependencies
npm i preact preact-router slugify webpack
- install devDependencies
npm i -D @babel/cli @babel/core @babel/plugin-transform-react-jsx @babel/preset-env babel-loader webpack-cli webpack-dev-server
"scripts":{
"start": "webpack-dev-server --content-base public --port 4444",
"build": "webpack"
}
npm start
andnpm build
to compile
- index.js
- directories for
services
,containers
, andcomponents
services
contains get request for any APIcontainers
contains components that contain subcomponents and state of the app, recommended to map containers to routescomponents
components that don't have a state (contains parts of interface (ex: Header.js, Post.js, List.js, Application.js (Applications.js handles routing w/preact-router
module)))
- for build reference, using Preact.js, and this outdated tutorial