Skip to content

Instantly share code, notes, and snippets.

@startswithaj
Forked from simon-lang/project-init.sh
Created December 1, 2016 02:48
Show Gist options
  • Save startswithaj/a1e5e53070cbe12a4eb4c144f35e0e1b to your computer and use it in GitHub Desktop.
Save startswithaj/a1e5e53070cbe12a4eb4c144f35e0e1b to your computer and use it in GitHub Desktop.
project-init.sh
# project init
mkdir project-name
cd project-name
touch README.md
mkdir src dist
echo "console.log('hello world')" > src/entry.js
echo '<script src="bundle.js"></script>' > dist/index.html
# git init
git init
ignore node_modules
ignore npm-debug.log
git add -A
git commit -m "git init"
# git init (optional)
TODO: ADD REMOTE
git config user.name "Simon Lang"
git config remote.origin.push HEAD
# npm init
yes '' | yarn init
```
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server"
},
```
git add package.json
git commit -m "npm init"
# webpack init
yarn add webpack webpack-dev-server webpack-init
node_modules/.bin/webpack-init
```
entry: './src/entry.js',
output: {
path: './dist/',
filename: 'bundle.js',
publicPath: ''
},
devServer: {
contentBase: "./dist",
},
````
git add -A
git commit -m "webpack init"
# typescript
yarn add typescript ts-loader tslint ts-jest
# VSCode "Typings Auto Installer", run command "Typings: install definitions for all dependencies"
./node_moudles/.bin/tsc -init
./node_moudles/.bin/tslint -init
```
{
test: /\.tsx?$/,
loader: 'ts-loader'
}
```
tsconfig.json
```
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"outDir": "./dist/",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"jsx": "react",
"sourceMap": true,
"noImplicitAny": true,
"noEmitOnError": true
},
"files": [
"./src/app.tsx"
],
"exclude": [
"node_modules"
]
}
```
# react
yarn add react react-dom babel-preset-react
```
import ReactDOM from 'react-dom'
import React from 'react'
class HelloWorld extends React.Component {
render() {
return <h1>Hello World!!!</h1>
}
}
document.addEventListener('DOMContentLoaded', (event) => {
ReactDOM.render(<HelloWorld />, document.getElementById('mount-point'))
})
```
# es6
yarn add babel-loader babel-core babel-preset-es2015
`eslint --init` or [.eslintrc.json](https://bitbucket.org/simonlang/react-tutorial/raw/9f21dd5fac8987b59de033f435646e0bd7d953e7/.eslintrc.json)
```
{
test: /.js?$/,
loader: 'babel',
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['es2015', 'react']
}
},
```
# css
yarn add style-loader css-loader
```
{
test: /\.css$/,
loader: 'style!css'
},
```
# stylus
yarn add stylus stylus-loader
```
{
test: /\.styl$/,
loader: 'style!css!stylus-loader'
},
```
mkdir -p src/style
echo "body\n color blue" > src/style/main.styl
echo "\n\nrequire('./style/main.styl')" >> src/entry.js
# makefile
```
build: install
npm run dist
clean:
rm -rf dist
test: install
npm test
lint: install
npm run lint
dev: install
npm run dev
install: node_modules
.PHONY: test install lint
node_modules:
npm install
touch node_modules
```
convert to tabs
## libs
https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css
https://unpkg.com/angular@1.5.9/angular.js
# check it works
make dev
open http://localhost:8080/webpack-dev-server/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment