Skip to content

Commit

Permalink
Merge pull request #3736 from alibaba/fix/mutilple-task-resource
Browse files Browse the repository at this point in the history
feat: support browser history
  • Loading branch information
SoloJiang authored Oct 29, 2020
2 parents 9c23841 + 4f69919 commit 8846aff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
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);
// 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

0 comments on commit 8846aff

Please sign in to comment.