From 05d48cbc4051f16cdad41cbb3e1d9fb19b1936d6 Mon Sep 17 00:00:00 2001 From: Raku-Le Date: Wed, 6 Jan 2021 16:58:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(npm-init):=20template=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit template初始化 --- build/webpack.config.js | 8 ++++---- src/create.js | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/webpack.config.js b/build/webpack.config.js index 0c2534a..f54e10e 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -4,7 +4,7 @@ const SpeedMeasurePlugin = require('speed-measure-webpack-plugin') const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') const baseConfig = require('./webpack.base.config') const devConfig = require('./webpack.dev.config') -const proConfig = require('./webpack.pro.config') +const proConfig = require('./webpack.pro.config')() const smp = new SpeedMeasurePlugin() @@ -18,13 +18,13 @@ module.exports = (env, argv) => { proConfig.plugins[0] = new webpack.DefinePlugin({ HTTP_ENV: JSON.stringify('test'), }) - return proConfig + return () => proConfig })() - default: return proConfig + default: return () => proConfig } })() : (() => { proConfig.plugins.push(new BundleAnalyzerPlugin()) - return proConfig + return () => proConfig })() return argv.isAnalyze ? smp.wrap(merge(baseConfig(env, argv), config(env, argv))) : merge(baseConfig(env, argv), config(env, argv)) diff --git a/src/create.js b/src/create.js index 5913f5f..2de83ab 100644 --- a/src/create.js +++ b/src/create.js @@ -89,6 +89,7 @@ async function create(projectName, options) { path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2) ) + execSync('npm init --y', { cwd: targetDir, stdio: 'inherit' }) } if (fs.existsSync(path.join(__dirname, '../build'))) { fs.copySync(path.join(__dirname, '../build'), path.join(targetDir, './build'))