Skip to content

Commit

Permalink
feat: 重写数据代理方法
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongzhi107 committed Nov 25, 2019
1 parent 004e517 commit 07f4e38
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"commander": "^2.20.0",
"cookie-parser": "^1.4.4",
"css-loader": "^3.0.0",
"dace-router": "^1.0.0",
"dotenv": "^8.0.0",
"eslint": "^5.16.0",
"eslint-config-qunar": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { hydrate } from 'react-dom';
import { loadableReady } from '@loadable/component';
import { renderRoutes } from 'react-router-config';
import routes from './routes';
import routes from './ssrRoutes';

const initialProps = window.INITIAL_STATE || {};

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import NotFound from './components/NotFound';
import addProxy from './utils/addProxy';
import addStatic from './utils/addStatic';
import document from './document';
import routes from './routes';
import routes from './ssrRoutes';

const server = express();

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/utils/defaultEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
// 代理请求规则(需JSON.stringify)
DACE_PROXY: '',

// 是否可以将请求代理到数据文件
DACE_PROXY_TO_FILE: 'false',

// 编译产物对外服务访问使用的 URL
DACE_PUBLIC_PATH: '/',

Expand Down Expand Up @@ -65,6 +68,9 @@ export default {
// 浏览器端编译入口文件位置
DACE_PATH_CLIENT_ENTRY: 'src/client.js',

// 自定义路由文件位置
DACE_PATH_ROUTES: '',

// node_modules 目录位置
DACE_PATH_NODE_MODULES: 'node_modules',

Expand Down
4 changes: 2 additions & 2 deletions src/webpack/config/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default ({
strictExportPresence: true,
rules: [
{
test: /\/routes/,
test: /\/ssrRoutes/,
// 多个 loaders 按 `从后往前` 的顺序执行
use: [
{
Expand Down Expand Up @@ -334,7 +334,7 @@ export default ({
nodeExternals({
whitelist: [
IS_DEV ? 'webpack/hot/poll?300' : null,
/dace/, // <-- #13
/\/dace\//, // <-- #13
/\.(eot|woff|woff2|ttf|otf)$/,
/\.(svg|png|jpg|jpeg|gif|ico)$/,
/\.(mp4|mp3|ogg|swf|webp)$/,
Expand Down

0 comments on commit 07f4e38

Please sign in to comment.