Home > Web Front-end > JS Tutorial > body text

vue-cli 2.x project optimization introduces local static library files

不言
Release: 2018-07-09 14:43:36
Original
2250 people have browsed it

This article mainly introduces the introduction of local static library files about vue-cli 2.x project optimization. It has certain reference value. Now I share it with you. Friends in need can refer to it

vue -cli Place the static resource files in the static folder and quote:

1. Copy the corresponding xxx.min.js under node_modules to the project static folder
2.index.html Modify
Add script introduction

<script src="static/js/vue.min.js"></script>
<script src="static/js/vue-router.min.js"></script>
Copy after login

3. Modify the build/webpack.base.conf.js file:
Comment out the following line

resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      // 'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
    }
  },
Copy after login

Add the externals part (externals and resource are the same class).

    externals: {
        'vue': 'Vue',
        'vue-router': 'VueRouter'
    },
Copy after login
  • demo address: https://github.com/cag2050/vu...

The above is the entire content of this article, I hope It will be helpful for everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How vue solves the problem of refresh failure after addRoutes dynamically adds routes

Self-made vue component communication plug-in Use mixin to write plug-ins

The road to Vue activity creation project design and navigation bar development

The above is the detailed content of vue-cli 2.x project optimization introduces local static library files. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!