Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix(web): 修正配置 rootDir 不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed May 10, 2020
1 parent c0c3862 commit a53512e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/remax-cli/src/build/utils/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export function generatePageRoutesInfo(options: Options, pages: EntryInfo[]) {
};
});
}

export function entryName(options: Options) {
return `./${options.rootDir}/remax-entry.js`;
}
6 changes: 3 additions & 3 deletions packages/remax-cli/src/build/webpack/config.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import getAppConfig from '../utils/getAppConfig';
import { cssConfig, addCSSRule, RuleConfig } from './config/css';
import baseConfig from './baseConfig';
import API from '../../API';
import { generatePageRoutesInfo } from '../utils/web';
import { generatePageRoutesInfo, entryName } from '../utils/web';

function prepare(options: Options) {
const entries = getEntries(options);
Expand All @@ -37,7 +37,7 @@ export default function webpackConfig(api: API, options: Options): webpack.Confi

const { entries, appConfig, publicPath } = prepare(options);

config.entry('index').add('./src/remax-entry.js');
config.entry('index').add(entryName(options));

config.devtool(process.env.NODE_ENV === 'development' ? 'cheap-module-source-map' : false);
config.output.publicPath(publicPath);
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function webpackConfig(api: API, options: Options): webpack.Confi

const entryTemplate = fs.readFileSync(path.resolve(__dirname, '../../../template/entry.js.ejs'), 'utf-8');
const virtualModules = new VirtualModulesPlugin({
'./src/remax-entry.js': ejs.render(entryTemplate, {
[entryName(options)]: ejs.render(entryTemplate, {
pages: generatePageRoutesInfo(options, entries.pages),
appConfig,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Compiler } from 'webpack';
import { Options } from '@remax/types';
import getAppConfig from '../../utils/getAppConfig';
import getEntries from '../../../getEntries';
import { generatePageRoutesInfo } from '../../utils/web';
import { generatePageRoutesInfo, entryName } from '../../utils/web';

const PLUGIN_NAME = 'RemaxWebEntryWatcherPlugin';

Expand All @@ -29,7 +29,7 @@ export default class WebEntryWatcherPlugin {
const appConfig = getAppConfig(this.remaxOptions);

this.virtualModules.writeModule(
'./src/remax-entry.js',
entryName(this.remaxOptions),
ejs.render(this.entryTemplate, {
pages: generatePageRoutesInfo(this.remaxOptions, entries.pages),
appConfig,
Expand Down

0 comments on commit a53512e

Please sign in to comment.