创建YAPI

This commit is contained in:
waliang.wang 2017-07-05 14:10:06 +08:00
parent 22fcd60c6b
commit 770a70f5e3
12 changed files with 169 additions and 3 deletions

12
client/App.js Normal file
View File

@ -0,0 +1,12 @@
import React, { Component } from 'react'
import Routes from './routes'
import './styles/cs.scss'
// import './styles/cs.less'
class App extends Component {
render() {
return <Routes />
}
}
export default App

View File

@ -0,0 +1,8 @@
import React from 'react'
import Logo from './Header/Logo/Logo.js'
export default function () {
return (
<Logo />
)
}

View File

@ -0,0 +1,7 @@
import React from 'react'
export default _ => {
return (
<p>这是LOGO3</p>
)
}

View File

@ -0,0 +1,11 @@
import React from 'react'
import Header from '../../components/Header.js'
export default _ => {
return (
<acticle>
<Header />
<h3>首页</h3>
</acticle>
)
}

View File

@ -0,0 +1,5 @@
import Home from './Home/Home.js'
export {
Home
}

8
client/index.js Normal file
View File

@ -0,0 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
ReactDOM.render(
<App />,
document.getElementById('yapi')
)

1
client/model/index.js Normal file
View File

@ -0,0 +1 @@

11
client/routes.js Normal file
View File

@ -0,0 +1,11 @@
import React from 'react'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import { Home } from './containers/index'
export default store => {
return (
<Router>
<Route path="/" component={ Home } />
</Router>
)
}

5
client/styles/cs.scss Normal file
View File

@ -0,0 +1,5 @@
html {
body {
border: 1px #000 solid;
}
}

12
index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>my yApi</title>
</head>
<body>
<div id="yapi"></div>
<script src="./build/index.js"></script>
</body>
</html>

View File

@ -30,14 +30,42 @@
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"fs-extra": "^3.0.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-watch": "^4.3.11",
"nodemon": "^1.11.0"
"nodemon": "^1.11.0",
"axios": "^0.16.2",
"babel": "^6.5.2",
"babel-core": "^6.8.0",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-register": "^6.9.0",
"babel-runtime": "^6.9.2",
"buffer-shims": "^1.0.0",
"extract-text-webpack-plugin": "^2.1.2",
"less": "^2.7.2",
"less-loader": "^4.0.4",
"node-sass": "^4.5.3",
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"react-router-dom": "^4.1.1",
"react-router-redux": "^4.0.8",
"react-scripts": "1.0.10",
"sass-loader": "^6.0.6",
"scss-loader": "0.0.1",
"webpack": "^2.0.0",
"webpack-node-externals": "^1.6.0",
"css-loader": "^0.28.4",
"style-loader": "^0.18.2"
},
"engines": {
"node": ">= 6.0.0",

58
webpack.config.js Normal file
View File

@ -0,0 +1,58 @@
const webpack = require('webpack')
const path = require('path')
const nodeExternals = require('webpack-node-externals')
const ExtractTextPlugin = require("extract-text-webpack-plugin")
module.exports = {
// context: 如果不通过path.resolve 配置入口访问路径 watch: true失效
context: path.resolve('./client'),
entry: {
index: './index.js',
},
output: {
// filename: 编译的文件名 仅用于命名每个文件
// [name]: 多入口形式 入口文件名替换这里的name
// [chunkhash: num]: 入口文件的hash值 用于修改后清空缓存
// filename: '[name].[chunkhash:3].js',
filename: './[name].js',
// 包存放的目录
path: path.resolve('./build'),
},
// target: 'node',
// externals: [nodeExternals()],
module: {
noParse: /\.css$/,
rules: [
{
test: /\.scss$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "sass-loader"
}
]
},
{
test: /\.(jsx|js)?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015', 'react']
}
}
}
]
},
watch: true
}