淘先锋技术网

首页 1 2 3 4 5 6 7

我在*.vue,main.js中都没有引入jquery。但是用 webpack-bundle-size-analyzer 分析bundle文件的时候,显示jquery已经引入了依赖:$ webpack --json | webpack-bundle-size-analyzer

vue: 274.93 KB (26.7%)

jquery: 261.76 KB (25.4%)

webuploader: 254.54 KB (24.7%)

buffer: 47.47 KB (4.61%)

axios: 36.19 KB (3.52%)

cuint: 24.69 KB (2.40%)

xxhashjs: 20.97 KB (2.04%)

vue-style-loader: 6.54 KB (0.635%)

setimmediate: 6.32 KB (0.614%)

process: 5.29 KB (0.514%)

base64-js: 3.39 KB (0.329%)

vue-loader: 2.83 KB (0.275%)

css-loader: 2.21 KB (0.214%)

ieee754: 2.01 KB (0.195%)

timers-browserify: 1.33 KB (0.129%)

is-buffer: 698 B (0.0662%)

webpack: 488 B (0.0463%)

isarray: 132 B (0.0125%)

: 77.6 KB (7.54%)

main.js://import 'babel-polyfill';

import Vue from 'vue'

import ImageUpload from './ImageUpload.vue'

import AttachUpload from './AttachUpload.vue'

import Draggable from './directives/draggable'

Vue.component('imageupload',ImageUpload);

Vue.component('attachupload',AttachUpload);

Vue.directive('draggable',Draggable);

//var jQuery = window.jQuery;

new Vue({

el: '#app',

//render: h => h(App)

});

webpack.config.js:var path = require('path')

var webpack = require('webpack')

module.exports = {

entry: './src/main.js',

output: {

path: path.resolve(__dirname, './dist'),

publicPath: '/dist/',

filename: 'build.js'

},

module: {

rules: [

{

test: /\.vue$/,

loader: 'vue-loader',

options: {

loaders: {

}

// other vue-loader options go here

}

},

{

test: /\.js$/,

loader: 'babel-loader',

exclude: /node_modules/

},

{

test: /\.(png|jpg|gif|svg)$/,

loader: 'file-loader',

options: {

name: '[name].[ext]?[hash]'

}

}

]

},

resolve: {

alias: {

'vue$': 'vue/dist/vue.esm.js'

}

},

devServer: {

historyApiFallback: true,

noInfo: true

},

performance: {

hints: false

},

devtool: '#eval-source-map'

}

if (process.env.NODE_ENV === 'production') {

module.exports.devtool = '#source-map'

// http://vue-loader.vuejs.org/en/workflow/production.html

module.exports.plugins = (module.exports.plugins || []).concat([

new webpack.DefinePlugin({

'process.env': {

NODE_ENV: '"production"'

}

}),

new webpack.optimize.UglifyJsPlugin({

sourceMap: true,

compress: {

warnings: false

}

}),

new webpack.LoaderOptionsPlugin({

minimize: true

})

])

}