From dec160fd1e9316700d3f5cf979566c7853bd72be Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 27 Nov 2017 10:51:54 +0800 Subject: [PATCH] chore: change inject package dependencies --- build/webpack.dev.conf.js | 4 +--- build/webpack.prod.conf.js | 4 +--- src/utils/index.js | 4 +++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 15474fb4..994399eb 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -6,7 +6,6 @@ var merge = require('webpack-merge') var baseWebpackConfig = require('./webpack.base.conf') var HtmlWebpackPlugin = require('html-webpack-plugin') var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') -var dependencies = require('../package.json').dependencies // add hot-reload related code to entry chunks Object.keys(baseWebpackConfig.entry).forEach(function (name) { @@ -26,8 +25,7 @@ module.exports = merge(baseWebpackConfig, { cache: true, plugins: [ new webpack.DefinePlugin({ - 'process.env': config.dev.env, - 'DEPENDENCIES': JSON.stringify(dependencies) + 'process.env': config.dev.env }), // https://github.com/glenjamin/webpack-hot-middleware#installation--usage new webpack.HotModuleReplacementPlugin(), diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 0e2b0562..93992969 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -8,7 +8,6 @@ var CopyWebpackPlugin = require('copy-webpack-plugin') var HtmlWebpackPlugin = require('html-webpack-plugin') var ExtractTextPlugin = require('extract-text-webpack-plugin') var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') -var dependencies = require('../package.json').dependencies var env = config.build[process.env.env_config+'Env'] @@ -34,8 +33,7 @@ var webpackConfig = merge(baseWebpackConfig, { plugins: [ // http://vuejs.github.io/vue-loader/en/workflow/production.html new webpack.DefinePlugin({ - 'process.env': env, - 'DEPENDENCIES': JSON.stringify(dependencies) + 'process.env': env }), new webpack.optimize.UglifyJsPlugin({ compress: { diff --git a/src/utils/index.js b/src/utils/index.js index dccca0ca..ee74ce57 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -268,5 +268,7 @@ export function deepClone(source) { // get dependencies verison from package.json by webpack.DefinePlugin export function getVersion(name) { - return DEPENDENCIES[name] // eslint-disable-line + import('../../package').then(p => { + return p.dependencies[name] + }) }