From 4cbcad2fd978d0cc471a90874ee5964940b32242 Mon Sep 17 00:00:00 2001 From: nankaNULL <534129087@qq.com> Date: Mon, 25 Mar 2019 09:37:40 +0800 Subject: [PATCH 01/35] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b08fa5a..1daee8f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # my-react -尝试搭建脚手架 +typescript-react-webpack脚手架,参考pc-react-ant.design + 云日志 + 各种文档 From f0c9c6b1a039d27ddd22a5601c457a6749e23f34 Mon Sep 17 00:00:00 2001 From: nankaNULL <534129087@qq.com> Date: Wed, 8 May 2019 11:40:17 +0800 Subject: [PATCH 02/35] =?UTF-8?q?=E5=90=AF=E7=94=A8=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/dev.js | 19 +++++++++---------- src/api/url.js | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build/dev.js b/build/dev.js index ba4afa8..ea56f97 100644 --- a/build/dev.js +++ b/build/dev.js @@ -87,16 +87,15 @@ module.exports = { contentBase: buildPath, publicPath: '/', historyApiFallback: true, - // disableHostCheck: true, - // compress: true, - // hot: true, // 开启模块热替换功能 - // inline:true, // 自动刷新网页实现实时预览 - // proxy: [{ - // path: '/api', - // // target: 'http://172.16.0.98:8788',//本地 - // target: 'http://47.101.183.209:8788',//测试 - // changeOrigin: true - // }] + disableHostCheck: true, + compress: true, + hot: true, // 开启模块热替换功能 + inline:true, // 自动刷新网页实现实时预览 + proxy: [{ + path: '/users', + target: 'https://api.github.com',//测试 + changeOrigin: true + }] } }; diff --git a/src/api/url.js b/src/api/url.js index bd2428e..0f86417 100644 --- a/src/api/url.js +++ b/src/api/url.js @@ -1,10 +1,10 @@ export default { getTheData:{ method:'get', - url:'https://api.github.com/users/chriscoyier/repos' + url:'/users/chriscoyier/repos' }, getErrData:{ method:'get', - url:'https://api.github.com/users/chrissycoyier/repos' + url:'/users/chrissycoyier/repos' } } \ No newline at end of file From 73259d09a10dedb1ae4d32e7cf063bcb44a27ec6 Mon Sep 17 00:00:00 2001 From: nankaNULL <534129087@qq.com> Date: Thu, 9 May 2019 10:31:19 +0800 Subject: [PATCH 03/35] =?UTF-8?q?dev&prod=E7=8E=AF=E5=A2=83=E4=B8=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/dev.js | 11 ++--------- build/prod.js | 21 ++++++++++++--------- package.json | 4 +++- src/index.html | 25 +++++++++++++++---------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/build/dev.js b/build/dev.js index ea56f97..0e6fefc 100644 --- a/build/dev.js +++ b/build/dev.js @@ -1,6 +1,5 @@ const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -// const CopyWebpackPlugin = require('copy-webpack-plugin'); const path = require('path'); const buildPath = path.resolve(__dirname, '../dist'); // const theme = require('../antd-theme.js'); @@ -72,14 +71,8 @@ module.exports = { template: 'index.html', }), new webpack.NamedModulesPlugin(), - // new webpack.HotModuleReplacementPlugin(), - // new CopyWebpackPlugin([ - // {from: path.resolve(__dirname,'../public/config'),to:'config'}, - // {from: path.resolve(__dirname,'../public/mock'),to:'mock'}, - // {from: path.resolve(__dirname,'../public/images'),to:'images'}, - // {from: path.resolve(__dirname,'../public/fonts'),to:'fonts'}, - // {from: path.resolve(__dirname,'../public/pages'),to:'pages'} - // ]) + new webpack.HotModuleReplacementPlugin(), + new webpack.DefinePlugin({__PRODUCTION: JSON.stringify(false)}), ], devServer: { host: '0.0.0.0', diff --git a/build/prod.js b/build/prod.js index d17504e..12072c1 100644 --- a/build/prod.js +++ b/build/prod.js @@ -1,5 +1,6 @@ const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); const path = require('path'); const buildPath = path.resolve(__dirname, '../dist'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -9,8 +10,8 @@ module.exports = { mode:'production', context:path.resolve(__dirname, '../src'), // 解析起点 entry:{ - vendor: ['react'], - app: ['./main.js'] + vendor: ['react', 'react-dom', 'react-router', 'moment'], + app: ['babel-polyfill','./main.js'] }, output: { path: buildPath, // 输出文件存放在本地的目录 @@ -102,6 +103,7 @@ module.exports = { new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', + title: 'webpack-react' }), new webpack.NamedModulesPlugin(), new webpack.optimize.OccurrenceOrderPlugin(true), @@ -109,13 +111,14 @@ module.exports = { filename: 'css/[name].[hash].css', chunkFilename: 'css/[name].[hash].css' }), - // new CopyWebpackPlugin([ - // {from: path.resolve(__dirname,'../public/config'),to:'config'}, - // {from: path.resolve(__dirname,'../public/mock'),to:'mock'}, - // {from: path.resolve(__dirname,'../public/images'),to:'images'}, - // {from: path.resolve(__dirname,'../public/fonts'),to:'fonts'}, - // {from: path.resolve(__dirname,'../public/pages'),to:'pages'} - // ]), + new CopyWebpackPlugin([ + {from: path.resolve(__dirname,'../public/md'),to:'md'}, + // {from: path.resolve(__dirname,'../public/config'),to:'config'}, + // {from: path.resolve(__dirname,'../public/mock'),to:'mock'}, + // {from: path.resolve(__dirname,'../public/images'),to:'images'}, + // {from: path.resolve(__dirname,'../public/fonts'),to:'fonts'}, + // {from: path.resolve(__dirname,'../public/pages'),to:'pages'} + ]), new webpack.DefinePlugin({ __PRODUCTION: JSON.stringify(true) }), diff --git a/package.json b/package.json index 730244e..7b1a5b4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "webpack-dev-server --progress --colors --config ./build/dev.js", "test-watch": "karma start --auto-watch --no-single-run", "start": "npm run dev", - "preview": "pushstate-server ./dist 1234" + "preview": "http-server dist/ -P https://api.github.com" }, "dependencies": { "antd": "^3.14.1", @@ -27,6 +27,7 @@ "babel-plugin-import": "^1.6.2", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-runtime": "^6.6.0", + "babel-polyfill": "^6.26.0", "babel-preset-env": "^1.6.0", "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", @@ -35,6 +36,7 @@ "css-loader": "^0.28.7", "file-loader": "^1.1.11", "html-webpack-plugin": "^3.2.0", + "http-server": "^0.11.1", "less": "^2.7.3", "less-loader": "^4.0.5", "mini-css-extract-plugin": "^0.4.1", diff --git a/src/index.html b/src/index.html index c7f3c39..234444f 100644 --- a/src/index.html +++ b/src/index.html @@ -1,12 +1,17 @@ - + +
- - - -