Skip to content

Commit

Permalink
implementing #103
Browse files Browse the repository at this point in the history
  • Loading branch information
Diablohu committed Jun 28, 2019
1 parent 15c9f26 commit 2efb9cd
Show file tree
Hide file tree
Showing 10 changed files with 539 additions and 368 deletions.
8 changes: 2 additions & 6 deletions packages/koot-webpack/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,7 @@ module.exports = async (kootConfig = {}) => {
);
// webpackLoggedError = true
reject(
`webpack error: [${TYPE}-${STAGE}-${ENV}] ${
info.errors
}`
`webpack error: [${TYPE}-${STAGE}-${ENV}] ${info.errors}`
);
return error(info.errors);
}
Expand Down Expand Up @@ -936,9 +934,7 @@ module.exports = async (kootConfig = {}) => {
);
webpackLoggedError = true;
reject(
`webpack error: [${TYPE}-${STAGE}-${ENV}] ${
info.errors
}`
`webpack error: [${TYPE}-${STAGE}-${ENV}] ${info.errors}`
);
return error(info.errors);
}
Expand Down
34 changes: 34 additions & 0 deletions packages/koot-webpack/factory-config/_defaults/spa.server.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const webpack = require('webpack');
const common = require('../common');

const factoryConfig = async ({
pathRun
// CLIENT_DEV_PORT,
}) => {
// let { RUN_PATH, CLIENT_DEV_PORT, APP_KEY } = opt

return {
mode: 'development',
devtool: 'source-map',
target: 'async-node',
node: {
__dirname: true
},
watch: false,
output: {
filename: '[name].js',
chunkFilename: 'chunk.[chunkhash].js',
path: `${pathRun}/${common.outputPath}/_server`
// publicPath: `/[need_set_in_app:__webpack_public_path__]/`,
// publicPath: `/`,
},
plugins: [
new webpack.DefinePlugin({
__SPA__: true
})
],
externals: common.filterExternalsModules()
};
};

module.exports = async opt => await factoryConfig(opt);
19 changes: 17 additions & 2 deletions packages/koot-webpack/factory-config/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,26 @@ module.exports = async (kootConfig = {}) => {
if (STAGE === 'server')
config = await transformConfigServer(kootBuildConfig);

// ========================================================================
// ====================================================================
//
// SPA 生产环境
//
// ====================================================================
if (ENV === 'prod' && STAGE === 'client' && TYPE === 'spa') {
process.env.WEBPACK_BUILD_STAGE = 'server';
if (!Array.isArray(config)) config = config[0];
config = [
...config,
...(await transformConfigServer(kootBuildConfig))
];
process.env.WEBPACK_BUILD_STAGE = 'client';
}

// ====================================================================
//
// 模式: analyze
//
// ========================================================================
// ====================================================================

if (analyze) {
if (Array.isArray(config)) config = config[0];
Expand Down
Loading

0 comments on commit 2efb9cd

Please sign in to comment.