VUE-CLI introduction of Jquery,bootstrap,popper

Source: Internet
Author: User

1. Installing plugins

NPM install jquery--save          //jquery plugin npm install bootstrap--save   //Bootstrap npm Install--save popper.js  //popper.js    

2. Modify the Webpack.base.conf.js configuration file under the build directory:

1) Add Webpack object: Var webpack=require (' Webpack ');

2) Add the following configuration to the Module.exports:

  plugins: [    new webpack.optimize.CommonsChunkPlugin (' Common '),    New  Webpack. Provideplugin ({      ' jquery ',      ' jquery ',      Popper: [' popper.js ', ' Default ']    })  ]

Webpack.base.conf.js configuration File Final code

' Use strict 'Const PATH= Require (' path ') Const Utils= require ('./utils ')) Const Config= require ('.. /config ') Const Vueloaderconfig= require ('./vue-loader.conf ')) Const Webpack= Require (' Webpack ')functionResolve (dir) {returnPath.join (__dirname, ' ... '), dir)} Module.exports={context:path.resolve (__dirname,‘.. /‘), entry: {app:'./src/main.js '}, Output: {path:config.build.assetsRoot, filename:' [Name].js ', PublicPath:process.env.NODE_ENV= = = ' Production '?Config.build.assetsPublicPath:config.dev.assetsPublicPath}, Resolve: {extensions: ['. js ', '. Vue ', '. JSON '], alias: {' vue$ ': ' Vue/dist/vue.esm.js ',      ' @ ': Resolve (' src ')),}}, module: {rules: [{test:/\.vue$/, Loader:' Vue-loader ', Options:vueloaderconfig}, {test:/\.js$/, Loader:' Babel-loader ', include: [Resolve (' src '), resolve (' test '), resolve (' node_modules/webpack-dev-server/client '))]}, {test:/\. (png|jpe?g|gif|svg) (\?. *)?$/, Loader:' Url-loader ', Options: {limit:10000, Name:utils.assetsPath (' Img/[name]. [Hash:7]. [ext] ')}}, {test:/\. (MP4|WEBM|OGG|MP3|WAV|FLAC|AAC) (\?. *)?$/, Loader:' Url-loader ', Options: {limit:10000, Name:utils.assetsPath (' Media/[name]. [Hash:7]. [ext] ')}}, {test:/\. (woff2?| EOT|TTF|OTF) (\?. *)?$/, Loader:' Url-loader ', Options: {limit:10000, Name:utils.assetsPath (' Fonts/[name]. [Hash:7]. [ext] ')}}]}, node: {//prevent Webpack from injecting useless setimmediate polyfill because Vue    //source contains it (although only uses it if it ' s native).Setimmediate:false,    //prevent Webpack from injecting mocks to Node native modules    //That does not make sense for the clientDgram: ' Empty ', FS:' Empty ', Net:' Empty ', TLS:' Empty ', child_process:' Empty '}, plugins: [NewWebpack.optimize.CommonsChunkPlugin (' Common '),    NewWebpack. Provideplugin ({$:' jquery ', JQuery:' jquery ', Popper: [' Popper.js ', ' Default ']    })  ]}
#在main. js in the Jquery,bootstrap JS and CSS through import to introduce the code as follows:
Import $ from ' jquery' bootstrap/dist/css/bootstrap.min.css' bootstrap/dist/js/bootstrap.min '

Finally reboot:

NPM Run Dev

VUE-CLI introduction of Jquery,bootstrap,popper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.