Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support browser history #3736

Merged
merged 3 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/plugin-app-base/src/config/default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module.exports = {
ignored: /node_modules/,
aggregateTimeout: 600,
},
// For mutilple task, web will occupy the server root route
writeToDisk: true,
historyApiFallback: true,
before(app) {
app.use((req, res, next) => {
// set cros for all served files
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-app-base/src/setBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module.exports = (api) => {
const { context, onHook } = api;
const { rootDir, userConfig } = context;

onHook('before.build.run', ({ config }) => {
onHook('before.build.run', ({ config: configs }) => {
try {
debug(config[0]);
debug(configs);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有 configs 这个参数。👉👉👉 config

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议修改 build-scripts 的参数

// eslint-disable-next-line no-empty
} catch (err) {}
});
Expand Down
18 changes: 13 additions & 5 deletions packages/plugin-app-base/src/setDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const openBrowser = require('react-dev-utils/openBrowser');
const chalk = require('chalk');
const qrcode = require('qrcode-terminal');
const path = require('path');
const fs = require('fs-extra');

const {
MINIAPP,
Expand Down Expand Up @@ -34,15 +35,22 @@ module.exports = function(api) {
}
return taskConfig.entry;
};
onHook('before.start.run', ({ config }) => {
webEntryKeys = Object.keys(getWebpackEntry(config, 'web'));
weexEntryKeys = Object.keys(getWebpackEntry(config, 'weex'));
krakenEntryKeys = Object.keys(getWebpackEntry(config, 'kraken'));
onHook('before.start.run', ({ config: configs }) => {
webEntryKeys = Object.keys(getWebpackEntry(configs, 'web'));
weexEntryKeys = Object.keys(getWebpackEntry(configs, 'weex'));
krakenEntryKeys = Object.keys(getWebpackEntry(configs, 'kraken'));
webMpa = userConfig.web && userConfig.web.mpa;
weexMpa = userConfig.weex && userConfig.weex.mpa;
krakenMpa = userConfig.kraken && userConfig.kraken.mpa;

// Remove outputDir when start devServer
const { outputDir = 'build' } = userConfig;
configs.forEach(config => {
fs.removeSync(path.resolve(rootDir, outputDir, config.name));
});

try {
debug(config);
debug(configs);
// eslint-disable-next-line no-empty
} catch (err) {}
});
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-app-base/src/setTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = (api) => {
const { onGetJestConfig, context, onHook } = api;
const { rootDir } = context;

onHook('before.test.run', ({ config }) => {
debug(JSON.stringify(config, null, 2));
onHook('before.test.run', ({ config: configs }) => {
debug(configs);
});

onGetJestConfig((jestConfig) => {
Expand Down