Skip to content

Commit

Permalink
Add site dev boilerplate.
Browse files Browse the repository at this point in the history
  • Loading branch information
EcutDavid committed Mar 28, 2016
1 parent fe01381 commit 79ed3cb
Show file tree
Hide file tree
Showing 11 changed files with 345 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* http://eslint.org/docs/rules/ */
{
"parser": "babel-eslint",
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"es6": true,
"jasmine": true,
"node": true
},
"rules": {
"camelcase": [2, { // http://eslint.org/docs/rules/camelcase
"properties": "never"
}],
"comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing
"before": false,
"after": true
}],
"comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style
// "curly": [2, "multi"],
"dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation
"allowKeywords": true
}],
"eol-last": 2,
"eqeqeq": 2,
"indent": [2, 2],
"jsx-quotes": [2, "prefer-single"],
"key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing
"beforeColon": false,
"afterColon": true
}],
"max-len": [1, 80, 4, {"ignoreComments": true}],
"no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
"no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
"no-empty": 2, // http://eslint.org/docs/rules/no-empty
"no-eq-null": 2,
"no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": [2, {"max": 2}],
"no-redeclare": 2, // disallow declaring the same variable more then once
"no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
"no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
"no-use-before-define": [2, "nofunc"],
"no-undef": 2,
"no-underscore-dangle": 0,
"no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
"no-unused-vars": [ 2, { "vars": "all", "args": "none" } ],
"no-var": 2,
"no-trailing-spaces": 2,

// "object-curly-spacing": [2, "always"],
"quotes": [2, "single", "avoid-escape"],

"semi": [2, "never"],
"space-after-keywords": 2, // http://eslint.org/docs/rules/space-after-keywords
"space-before-blocks": [2, "always"],
// "space-before-function-paren": [2, "always"],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"strict": [2, "never"], // http://eslint.org/docs/rules/strict
"vars-on-top": 2,
"no-warning-comments": [1, {
"terms": ["fixme"], "location": "anywhere"
}],

// React
"react/display-name": 0,
"react/jsx-boolean-value": 2,
"react/jsx-closing-bracket-location": 2,
"react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-multi-comp": 0,
"react/no-unknown-property": 2,
"react/prop-types": 1,
"react/react-in-jsx-scope": 2,
"react/self-closing-comp": 2,
"react/wrap-multilines": 2,
},
"plugins": [
"react"
]
}
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
bundle.js
*.map
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 David Guan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# 宁JS
The repository for the upcoming Nanjing Javascript Meetup


### Start development
```
npm i
npm run dev
```
Now go to http://localhost:6060/
11 changes: 11 additions & 0 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ningjs</title>
</head>
<body>
<div id='app'></div>
<script src='./bundle.js'></script>
</body>
</html>
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "ningjs",
"version": "0.0.1",
"description": "The repository for the upcoming Nanjing Javascript Meetup",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --devtool eval --colors --content-base build --port 6060",
"dist": "webpack --config webpack.config.prod.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jsconfcn/ningjs.git"
},
"keywords": [
"js"
],
"author": "Wiredcraft",
"license": "MIT",
"bugs": {
"url": "https://github.com/jsconfcn/ningjs/issues"
},
"devDependencies": {
"webpack": "^1.12.1",
"eslint-plugin-react": "^3.11.1",
"babel-core": "^5.8.24",
"babel-loader": "^5.3.2",
"babel-eslint": "^5.0.0-beta6",
"css-loader": "^0.18.0",
"node-sass": "^3.4.2",
"sass-loader": "^3.1.2",
"style-loader": "^0.12.3",
"autoprefixer-loader": "^3.2.0",
"json-loader": "^0.5.4"
},
"dependencies": {
"d3": "^3.5.16",
"lodash": "^4.6.1",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"topojson": "^1.6.24"
},
"homepage": ""
}
13 changes: 13 additions & 0 deletions src/Components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { Component } from 'react'

import './Header.scss'

export default class Header extends Component {
render() {
return (
<div className='header'>
<h1>ningjs</h1>
</div>
)
}
}
5 changes: 5 additions & 0 deletions src/Components/Header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.header{
h1{
color: #4A90E2
}
}
6 changes: 6 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'

import Header from 'Components/Header'

ReactDOM.render(<Header />, document.querySelector('#app'))
47 changes: 47 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = {
entry: [ './src/app.js' ],
output: {
path: __dirname + '/build',
filename: 'bundle.js'
},
resolve: {
modulesDirectories: [
'src',
'node_modules',
],
extensions: ['', '.json', '.js'],
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
}, {
test: /\.scss$/,
loader: 'style!css!autoprefixer?browsers=last 2 version!sass'
}, {
test: /\.css$/,
loader: 'style!css!autoprefixer?browsers=last 2 version'
}, {
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
}, {
test: /\.json$/,
loader: 'json'
},
]
}
}
65 changes: 65 additions & 0 deletions webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const webpack = require('webpack')

module.exports = {
devtool: 'cheap-module-source-map',
entry: [ './src/app.js' ],
output: {
path: __dirname + '/build',
filename: 'bundle.js'
},
resolve: {
modulesDirectories: [
'src',
'node_modules',
],
extensions: ['', '.json', '.js'],
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
}, {
test: /\.scss$/,
loader: 'style!css!autoprefixer?browsers=last 2 version!sass'
}, {
test: /\.css$/,
loader: 'style!css!autoprefixer?browsers=last 2 version'
}, {
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file'
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
}, {
test: /\.json$/,
loader: 'json'
},
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false,
dead_code: true,
}
}),
new webpack.DefinePlugin({
'process.env': {
// Useful to reduce the size of client-side libraries, e.g. react
NODE_ENV: JSON.stringify('production')
}
}),
]
}

0 comments on commit 79ed3cb

Please sign in to comment.