Skip to content

Commit 20e466e

Browse files
committed
first commit
1 parent b590e22 commit 20e466e

File tree

7 files changed

+598
-0
lines changed

7 files changed

+598
-0
lines changed

.babelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
"react",
4+
"es2015"
5+
],
6+
"env": {
7+
"dev": {
8+
"presets": ["react-hmre"]
9+
}
10+
},
11+
"plugins": ["transform-object-rest-spread"]
12+
}

LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#react-webpack project

package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "react-webpack-project",
3+
"version": "1.0.0",
4+
"description": "react-webpack project",
5+
"author": "alan",
6+
"private": true,
7+
"scripts": {
8+
"dev": "webpack-dev-server",
9+
"build": "webpack",
10+
"production": "webpack -p"
11+
},
12+
"dependencies": {
13+
"babel-plugin-transform-object-rest-spread": "^6.6.5",
14+
"base": "^0.8.1",
15+
"font-awesome": "^4.6.1",
16+
"header": "^0.1.1",
17+
"imports": "^1.0.0",
18+
"imports-loader": "^0.6.5",
19+
"jquery": "^2.2.4",
20+
"jquery.cookie": "^1.4.1",
21+
"react": "^0.14.7",
22+
"react-dom": "^0.14.7",
23+
"react-redux": "^4.4.5",
24+
"react-router": "^2.4.0",
25+
"redux": "^3.5.2",
26+
"redux-logger": "^2.6.1",
27+
"redux-thunk": "^2.1.0",
28+
"style": "0.0.3"
29+
},
30+
"devDependencies": {
31+
"babel-core": "^6.7.7",
32+
"babel-loader": "^6.2.4",
33+
"babel-preset-es2015": "^6.6.0",
34+
"babel-preset-react": "^6.5.0",
35+
"babel-preset-react-hmre": "^1.1.1",
36+
"css-loader": "^0.23.1",
37+
"extract-text-webpack-plugin": "^1.0.1",
38+
"file-loader": "^0.8.5",
39+
"font-awesome-webpack": "0.0.4",
40+
"html-loader": "^0.4.3",
41+
"html-webpack-plugin": "^2.16.0",
42+
"images": "^3.0.0",
43+
"node-sass": "^3.5.3",
44+
"npm-install-webpack-plugin": "^3.1.0",
45+
"sass-loader": "^3.2.0",
46+
"style-loader": "^0.13.1",
47+
"url-loader": "^0.5.7",
48+
"webpack": "^1.13.0",
49+
"webpack-dev-server": "^1.14.1",
50+
"webpack-merge": "^0.12.0"
51+
}
52+
}

src/assets/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>react-webpack-project</title>
6+
</head>
7+
<body>
8+
<div id="app" class="app">
9+
</div>
10+
</body>
11+
</html>

src/index.jsx

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//css
2+
require('style/base')
3+
require('style/header')
4+
require('style/style')
5+
require('style/swiper-3.3.1.min')
6+
require('style/home')
7+
8+
//js
9+
require('libs/swiper-3.3.1.jquery.min')
10+
require('libs/md5')
11+
require('libs/pv_click')
12+
require('jquery.cookie')
13+
14+
import React from 'react'
15+
import ReactDOM from 'react-dom'
16+
import {Provider} from 'react-redux'
17+
18+
import Home from './components/home/Home'
19+
import SubmitComp from './components/submit/Submit'
20+
import Order from './components/order/Order'
21+
import Summary from './components/summary/Summary'
22+
import Param from './components/param/Param'
23+
import PaySuccess from './components/paysuccess/PaySuccess'
24+
import Down from './components/down/Down'
25+
import Help from './components/help/Help'
26+
import Support from './components/support/Support'
27+
import Verify from './components/verify/Verify'
28+
29+
import {xunleiLogin} from './actions/verifyaction'
30+
31+
32+
import { Router, Route, IndexRoute, hashHistory } from 'react-router'
33+
import configureStore from './stores/store'
34+
35+
//关联reducers, store, actions
36+
const store = configureStore()
37+
38+
//初始化迅雷登录
39+
40+
xlQuickLogin.init({
41+
loginID: '156', // 注册ID:xlreading_pc
42+
registerID: 'xzb',
43+
uiTheme: 'popup',
44+
LOGIN_ID: '156',
45+
REGISTER_ID: 'xzb',
46+
//DEFUALT_BACKGROUND : 'http://misc.yuedu.xunlei.com/v3.0/img/logo.jpg',
47+
UI_THEME: 'popup',
48+
LOGIN_SUCCESS_FUNC: function () {
49+
var usernick = /usernick=(.*?)(?:;|$)/ig.exec(document.cookie)
50+
if(usernick && usernick.length>1){
51+
usernick = usernick[1]
52+
}
53+
var username = /usrname=(.*?)(?:;|$)/ig.exec(document.cookie)
54+
if(username && username.length>1){
55+
username = username[1]
56+
}
57+
store.dispatch(xunleiLogin('success',usernick || username))
58+
},
59+
LOGOUT_FUNC: function () {
60+
store.dispatch(xunleiLogin('nologin', ''))
61+
}
62+
});
63+
64+
ReactDOM.render(
65+
<Provider store={store}>
66+
<Router history={hashHistory}>
67+
<Route path="/" component={Home}/>
68+
<Route path="/home" component={Home}/>
69+
<Route path="/submit" component={SubmitComp}/>
70+
<Route path="/order" component={Order}/>
71+
<Route path="/summary" component={Summary}/>
72+
<Route path="/param" component={Param}/>
73+
<Route path="/paysuccess" component={PaySuccess}/>
74+
<Route path="/down" component={Down}/>
75+
<Route path="/help" component={Help}/>
76+
<Route path="/verify" component={Verify}/>
77+
<Route path="/support(/:id)" component={Support}/>
78+
</Router>
79+
</Provider>,
80+
document.getElementById('app')
81+
);

webpack.config.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
var path = require('path');
2+
const webpack = require('webpack');
3+
const merge = require('webpack-merge');
4+
const NpmInstallPlugin = require('npm-install-webpack-plugin');
5+
const HtmlWebpackPlugin = require('html-webpack-plugin')
6+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
7+
var cssExtractPlugin = new ExtractTextPlugin('css/[contenthash:16].css');
8+
9+
const TARGET = process.env.npm_lifecycle_event;
10+
11+
const PATHS = {
12+
src: path.join(__dirname, 'src'),
13+
dist: path.join(__dirname, 'dist')
14+
};
15+
16+
process.env.NODE_ENV = TARGET;
17+
process.env.BABEL_ENV = TARGET;
18+
19+
const common = {
20+
entry: {
21+
app:PATHS.src
22+
},
23+
output: {
24+
publicPath : '/',
25+
path: PATHS.dist,
26+
filename: 'bundle/bundle.js'
27+
},
28+
externals: [{
29+
}],
30+
module: {
31+
loaders: [
32+
{ test: /\.html$/, loader: "html" },
33+
{ test: /\.(css|scss)$/, exclude: /node_modules/, loader: ExtractTextPlugin.extract("style-loader", "css-loader", "scss-loader")},
34+
{ test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loaders: ['babel?cacheDirectory']},
35+
{ test: /\.woff(2)?(\?t=\d+)?$/, loader: "url-loader?name=font/[name].[ext]?[hash]&limit=10000&minetype=application/font-woff" },
36+
{ test: /\.(ttf|eot|svg)(\?t=\d+)?$/, loader: "file-loader?name=font/[name].[ext]?[hash:16]" },
37+
{ test: /\.jpg$/, loader: "file-loader?name=img/[name].[ext]?[hash:16]" },
38+
{ test: /\.png$/, loader: 'url-loader?name=img/[name].[ext]?[hash:16]&limit=8192' }
39+
]
40+
},
41+
plugins: [
42+
cssExtractPlugin,
43+
new HtmlWebpackPlugin({
44+
title: 'React',
45+
template:'./src/assets/index.html'
46+
})],
47+
resolve: {
48+
// you can now require('file') instead of require('file.coffee')
49+
root:[path.resolve('./src/assets')],
50+
extensions: ['', '.jsx','.js', '.json','.scss','.css']
51+
},
52+
htmlLoader: {
53+
ignoreCustomFragments: [/\{\{.*?}}/]
54+
}
55+
}
56+
57+
58+
if(TARGET === 'dev' || !TARGET) {
59+
module.exports = merge(common, {
60+
devtool: 'inline-source-map',
61+
devServer: {
62+
contentBase: PATHS.dist,
63+
64+
// Enable history API fallback so HTML5 History API based
65+
// routing works. This is a good default that will come
66+
// in handy in more complicated setups.
67+
historyApiFallback: false,
68+
hot: true,
69+
inline: true,
70+
progress: true,
71+
72+
// Display only errors to reduce the amount of output.
73+
stats: 'errors-only',
74+
75+
// Parse host and port from env so this is easy to customize.
76+
//
77+
// If you use Vagrant or Cloud9, set
78+
// host: process.env.HOST || '0.0.0.0';
79+
//
80+
// 0.0.0.0 is available to all network devices unlike default
81+
// localhost
82+
host: process.env.HOST,
83+
port: process.env.PORT
84+
},
85+
plugins: [
86+
new webpack.HotModuleReplacementPlugin(),
87+
new NpmInstallPlugin({
88+
save: true // --save
89+
})
90+
]
91+
});
92+
}
93+
94+
if(TARGET === 'build' || TARGET === 'production') {
95+
module.exports = merge(common, {
96+
plugins:[
97+
new webpack.DefinePlugin({
98+
'process.env.NODE_ENV': '"'+TARGET+'"'
99+
})
100+
]
101+
})
102+
}

0 commit comments

Comments
 (0)