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

Commit

Permalink
fix: #1739
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjue committed Nov 9, 2021
1 parent eb691a7 commit 31ed8a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/remax-cli/src/build/ProjectPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class ProjectPath {
this.builder = builder;
}

projectDir() {
return slash(path.join(this.builder.options.cwd));
}

outputDir() {
return slash(path.join(this.builder.options.cwd, this.builder.options.output));
}
Expand Down
1 change: 1 addition & 0 deletions packages/remax-cli/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function run(options: Options, api: API): webpack.Compiler {

if (options.target === 'web') {
// 兼容 herbox 所以用 require
// https://opendocs.alipay.com/mini/tool/00nxap
const WebBuilder = require('./WebBuilder').default;
return new WebBuilder(api, options).run();
} else {
Expand Down
14 changes: 13 additions & 1 deletion packages/remax-cli/src/build/webpack/config.mini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,19 @@ export default function webpackConfig(builder: Builder): webpack.Configuration {
.plugin('webpack-copy-plugin')
.use(CopyPlugin, [[{ from: builder.projectPath.publicDir(), to: builder.projectPath.outputDir() }]]);
}

// 判断是否是头条小程序,如果是的话将project.config.json复制到dist目录下
// 否则头条开发者工具无法识别Remax头条小程序
const miniProjectConfigJsonFile = `${builder.projectPath.projectDir()}/project.config.json`;
if (builder.options.target == 'toutiao' && fs.existsSync(miniProjectConfigJsonFile)) {
config.plugin('webpack-copy-plugin').use(CopyPlugin, [
[
{
from: miniProjectConfigJsonFile,
to: builder.projectPath.outputDir(),
},
],
]);
}
config.plugin('webpackbar').use(WebpackBar);
config.plugin('mini-css-extract-plugin').use(MiniCssExtractPlugin, [{ filename: `[name]${meta.style}` }]);
config.plugin('remax-optimize-entries-plugin').use(RemaxPlugins.OptimizeEntries, [meta]);
Expand Down

0 comments on commit 31ed8a0

Please sign in to comment.