Coder Social home page Coder Social logo

vue-cli使用相关 about blog HOT 2 OPEN

buddywang avatar buddywang commented on July 24, 2024
vue-cli使用相关

from blog.

Comments (2)

buddywang avatar buddywang commented on July 24, 2024

问题

怎么配置 Git hook--CLI服务

https://cli.vuejs.org/zh/guide/cli-service.html#git-hook

依赖需要 polyfill 时怎么处理--浏览器兼容性

https://cli.vuejs.org/zh/guide/browser-compatibility.html#polyfill

怎么构建一个多页应用

// vue.config.js
module.exports = {
  pages: {
    index: {
      // page 的入口
      entry: 'src/index/main.js',
      // 模板来源
      template: 'public/index.html',
      // 在 dist/index.html 的输出
      filename: 'index.html',
      // 当使用 title 选项时,
      // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
      title: 'Index Page',
      // 在这个页面中包含的块,默认情况下会包含
      // 提取出来的通用 chunk 和 vendor chunk。
      chunks: ['chunk-vendors', 'chunk-common', 'index']
    },
    // 当使用只有入口的字符串格式时,
    // 模板会被推导为 `public/subpage.html`
    // 并且如果找不到的话,就回退到 `public/index.html`。
    // 输出文件名会被推导为 `subpage.html`。
    subpage: 'src/subpage/main.js'
  }
}

webpack-chain

from blog.

buddywang avatar buddywang commented on July 24, 2024

配置开发环境的请求代理:devServer

该配置只在开发环境有效,具有类似Nginx的反向代理的功能,并提供以下功能:

  • 提供一个开发服务器,可以访问项目,并支持热模块替换

配置代理

当你的前端应用和后端 API 服务器没有运行在同一个主机上,你需要在开发环境下将 API 请求代理到 API 服务器(为了避免浏览器的同源策略问题)

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: '<url>',
        ws: true,
        changeOrigin: true
      },
      '/foo': {
        target: '<other_url>'
      }
    }
  }
}

详细配置看文档

参考

https://github.com/chimurai/http-proxy-middleware#proxycontext-config
https://webpack.js.org/configuration/dev-server/
https://cli.vuejs.org/zh/config/#devserver-proxy

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.