Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfucheng authored and liangfucheng committed Oct 14, 2017
2 parents eaef094 + f9b9d87 commit 4c089aa
Show file tree
Hide file tree
Showing 21 changed files with 6,393 additions and 175 deletions.
7 changes: 7 additions & 0 deletions .gitinore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/node_modules
/nginx
/dist
.DS_Store
npm-debug.log*
yarn*
yarn.lock
27 changes: 27 additions & 0 deletions build/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'
const path = require('path');

module.exports = {
template:{
title:'sinn-程序员的小客栈',
templatePath: 'public/index.html',
},
production: {
index: path.resolve(__dirname, '../dist/index.html'),
assetsRootPath: path.resolve(__dirname, '../dist'),
assetsStaticPath: 'static',
assetsPublicPath: '/',
productionSourceMap: true,
productionGzip: true,
productionGzipExtensions: ['js', 'css'],
},
development: {
port: process.env.PORT || 8000,
assetsRootPath: path.resolve(__dirname, '../dist'),
assetsStaticPath: 'static',
assetsPublicPath: '/',
autoOpenBrowser: true,
proxyTable: {},
cssSourceMap: false
}
}
1 change: 1 addition & 0 deletions build/dll/bundle.manifest.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions build/dll/vendor.d2e68332f99e1b953b12.dll.js

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions build/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
*/
const path = require('path');
const webpack = require('webpack');
const config = require('./config');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const baseConfig = config[process.env.NODE_ENV];

module.exports={
entry: ['./src/index.js'],
output: {
path: path.resolve(__dirname,'/../dist/'),
filename: 'bundle.js',
publicPath: '/assets/'
path: baseConfig.assetsRootPath,
filename: '[name].js',
publicPath: baseConfig.assetsPublicPath
},
module: {
rules: [
Expand All @@ -24,7 +26,7 @@ module.exports={
loaders: ['babel-loader']
},{
test: /\.css$/,
use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader?minimize' })
},{
test: /\.sass/,
use: ['style-loader','css-loader','sass-loader?outputStyle=expanded&indentedSyntax']
Expand All @@ -36,20 +38,22 @@ module.exports={
use: ['style-loader','css-loader','less-loader']
},{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: [ 'url-loader?limit=30000&name=/images/[name].[ext]' ]
loader: [ 'url-loader?limit=30000&name=images/[hash:8].[name].[ext]' ]
},
],
noParse: /node_modules\/(jquey|moment\.js)/
},
resolve: {
modules: [
path.join(__dirname, "src"),
path.join(__dirname, "../src"),
"node_modules"
],
extensions: [".js", ".json", ".jsx", ".css"],
alias: {
config: path.resolve(__dirname, 'src/config/'),
shared: path.resolve(__dirname, 'src/shared/'),
utils: path.resolve(__dirname, 'src/utils/'),
config: path.resolve(__dirname, '../src/config/'),
shared: path.resolve(__dirname, '../src/shared/'),
utils: path.resolve(__dirname, '../src/utils/'),
assets: path.resolve(__dirname, '../src/assets/')
}
},
};
Expand Down
73 changes: 48 additions & 25 deletions build/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* @ author sessionboy
* @ github https://github.com/sessionboy
Expand All @@ -8,60 +7,84 @@
const commonConfig = require('./webpack.base.js');
const path = require('path');
const webpack = require('webpack');
const config = require('./config');
const merge = require('webpack-merge')
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const baseConfig = config[process.env.NODE_ENV];

module.exports = function (env) {
return Object.assign({},commonConfig,{
module.exports = merge(commonConfig,{
cache: true,
devtool: 'source-map',
devtool: '#cheap-module-eval-source-map',
entry: {
bundle: [
app: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:8000',
'webpack/hot/only-dev-server',
'./src/index.js'
],
vendor: ['react','react-dom'],
lib: ['material-ui']
],
lib: ['moment','marked','react-s-alert','react-dropzone','react-stack-grid','whatwg-fetch','rc-upload']
},
output: {
path: path.join(__dirname, '/../dist/assets'),
filename: '[name].js',
publicPath: '/assets/',
sourceMapFilename: '[name].map'
sourceMapFilename: '[name].map',
filename: 'js/[name].[hash].js'
},
stats: {
colors: true,
errorDetails: true
},
devServer: {
historyApiFallback: true,
noInfo: false,
hot: true,
stats: 'minimal',
contentBase: './src/',
publicPath: '/assets/',
stats: 'errors-only',
contentBase: baseConfig.assetsRootPath,
publicPath: baseConfig.assetsPublicPath,
compress: true,
port: 8000,
proxy: {
'/api' : {
// target: 'http://www.boyagirl.com:8080',
target: 'http://localhost:8080',
target: 'http://www.boyagirl.com:8080',
// target: 'http://localhost:8080',
secure: false
},
}
}
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.DllReferencePlugin({
context: path.join(__dirname,'..'),
manifest: require.resolve("./dll/bundle.manifest.json")
}),
new CleanWebpackPlugin(['dist'],{
root: path.join(__dirname,'..'),
try: true
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new OpenBrowserPlugin({ url: 'http://localhost:8000' }),
new FriendlyErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
names: ['lib','vendor', 'manifest'],
names: ['app','lib'],
minChunks:2
}),
new HtmlWebpackPlugin({
inject: true,
template: config.template.templatePath
}),
new AddAssetHtmlPlugin({
filepath: path.resolve(__dirname,'dll/*.dll.js'),
outputPath: 'js',
publicPath:'/js',
includeSourcemap: false
}),
new ExtractTextPlugin({
filename: 'style.css',
filename: 'css/[name].[contenthash].css',
disable: false,
allChunks: true
})
}),
new OpenBrowserPlugin({ url: 'http://localhost:8000' })
]
})
}
65 changes: 38 additions & 27 deletions build/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,58 @@
const commonConfig = require('./webpack.base.js');
const path = require('path');
const webpack = require('webpack');
const config = require('./config');
const merge = require('webpack-merge');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
const baseConfig = config[process.env.NODE_ENV];

module.exports = function(env) {
return Object.assign({},commonConfig,{
module.exports = merge(commonConfig,{
cache: false,
devtool: false,
devtool: 'nosources-source-map',
entry: {
bundle: './src/index.js',
vendor: ['react','react-dom'],
lib: ['material-ui']
app: './src/index.js',
lib: ['moment','marked','react-s-alert','react-dropzone','react-stack-grid','whatwg-fetch','rc-upload']
},
output: {
path: path.join(__dirname, '/../dist/assets/'),
filename: '[name].js',
publicPath: '/assets',
sourceMapFilename: '[name].map'
path: baseConfig.assetsRootPath,
filename: 'js/[name].[chunkhash].js',
publicPath: baseConfig.assetsPublicPath
},
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: true,
new webpack.DllReferencePlugin({
context: path.join(__dirname,'..'),
manifest: require.resolve("./dll/bundle.manifest.json")
}),
new CleanWebpackPlugin(['dist'],{
root: path.join(__dirname,'..'),
try: true
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: { screw_ie8: true, keep_fnames: true },
compress: { screw_ie8: true },
comments: false,
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['lib','vendor', 'manifest'],
minChunks:2
}),
new ExtractTextPlugin({
filename: 'style.css',
disable: false,
allChunks: true
new webpack.optimize.CommonsChunkPlugin({
names: ['app','lib'],
minChunks:2
}),
new HtmlWebpackPlugin({
inject: true,
template: config.template.templatePath
}),
new AddAssetHtmlPlugin({
filepath: path.resolve(__dirname,'dll/*.dll.js'),
outputPath: 'js',
publicPath:'/js',
includeSourcemap: false
}),
new ExtractTextPlugin({
filename: 'css/[name].[contenthash].css',
disable: false,
allChunks: true
})
],
})
}
31 changes: 0 additions & 31 deletions nginx/conf/nginx.conf

This file was deleted.

9 changes: 0 additions & 9 deletions nginx/start.sh

This file was deleted.

18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
"index": "./src/index.js"
},
"dependencies": {
"add-asset-html-webpack-plugin": "^2.1.2",
"clean-webpack-plugin": "^0.1.17",
"cross-env": "^5.0.5",
"draft-js": "^0.10.0",
"dva": "^1.2.1",
"file-loader": "^0.10.0",
"font-awesome": "^4.7.0",
"friendly-errors-webpack-plugin": "^1.6.1",
"github-markdown-css": "^2.4.1",
"global": "^4.3.2",
"highlight": "^0.2.4",
"highlight.js": "^9.9.0",
"html-webpack-plugin": "^2.30.1",
"js-cookie": "^2.1.3",
"marked": "^0.3.6",
"material-ui": "^0.16.6",
Expand All @@ -25,6 +31,8 @@
"react-tap-event-plugin": "^2.0.1",
"redux-logger": "^2.7.4",
"url-loader": "^0.5.7",
"webpack": "^3.7.1",
"webpack-merge": "^4.1.0",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
Expand All @@ -51,14 +59,14 @@
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0"
},
"scripts": {
"dev": "webpack-dev-server --env=dev --progress --profile --colors",
"pro:test": "webpack-dev-server --env=prod --progress --profile --colors",
"start": "webpack --env=prod --progress --profile --colors",
"build": "atool-build",
"dll": "webpack --config webpack.dll.config.js -p",
"dev": "cross-env NODE_ENV=development webpack-dev-server --progress --profile --colors",
"pro:test": "cross-env NODE_ENV=production webpack-dev-server --progress --profile --colors",
"start": "npm run dll && npm run build",
"build": "cross-env NODE_ENV=production webpack -p",
"test": "atool-test-mocha ./src/**/*-test.js"
}
}
Binary file added public/banner-01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon.ico
Binary file not shown.
5 changes: 0 additions & 5 deletions put.sh

This file was deleted.

Loading

0 comments on commit 4c089aa

Please sign in to comment.