【前端开发】Vue-CLI4 &Vue-CLI3 与Vue-CLI2 的区别以及打包配置问题
发布日期:2021-05-10 06:28:51 浏览次数:12 分类:精选文章

本文共 3978 字,大约阅读时间需要 13 分钟。

���Vue-CLI2���������Vue-CLI4������������������������build���������config������������������������������������������������������������������������������������������������������������������������������������������

���������Vue-CLI2���Vue-CLI4���������������������������������������������������������������������������������

1. ������

  • Vue-CLI2���
    npm install -g vue-cli ��� cnpm install -g vue-cli
  • Vue-CLI4���
    npm install -g @vue/cli ��� cnpm install -g @vue/cli

2. ������

  • Vue-CLI2���
    npm uninstall -g vue-cli ��� cnpm uninstall -g vue-cli
  • Vue-CLI4���
    npm uninstall -g @vue/cli ��� cnpm uninstall -g @vue/cli

3. ������������

  • Vue-CLI2���
    vue init webpack my-project2
  • Vue-CLI4���
    vue create my-project4

4. ������������������

  • Vue-CLI2���
    • ������������������������������src���public���app���etc���������������
  • Vue-CLI4���
    • ���������������������������������������������������������������src���public���assests���������������

5. ������������

  • Vue-CLI2���
    npm run dev
  • Vue-CLI4���
    npm run serve

���������������������build���������config������������������������������������������������

6. ������������

  • ���������������������vue.config.js���������������������������������������������������������

    module.exports = {  // ������������������  publicPath: './',  // ������������������  outputDir: '../dist',  // ������������������  assetsDir: '../assests',  // HTML������������  indexPath: '../index.html',  // ���������������  filenameHashing: true,  // ���������������������������`undefined`  pages: {    index: {      entry: './src/index/main.js',      template: './public/index.html',      filename: 'index.html',      title: 'Index Page',      chunks: ['chunk-vendors', 'chunk-common', 'index']    },    // ������������������...  },  // ESLint������  lintOnSave: true,  // ������������������������������  runtimeCompiler: false,  //'Brien/loader'������������node_modules  transpileDependencies: [ /* ��������������������������������� */ ],  // ������������������source map  productionSourceMap: true,  // HTML������������������������  crossorigin: "",  // SRI������������������������  integrity: true,  // ������webpack������  configureWebpack: () => {},  // ������webpack���������  chainWebpack: () => {},  // webpack-dev-server������  devServer: {    open: process.platform === 'darwin',    host: 'localhost',    port: 8080,    https: false,    hotOnly: false,    proxy: {      '/api': {        target: 'http://app.ly.com',        changeOrigin: true,        secure: false,        pathRewrite: {          '^/api': ''        }      },      '/foo': {        target: 'other_url'      }    }  },  // CSS������������  css: {    extract: true,    sourceMap: false,    loaderOptions: {      css: {},      postcss: {}    },    modules: false  },  // ������������������  pwa: {},  // ������������������  pluginOptions: {    // ...  }}
  • ���vue.config.js������������������������������������������Vue CLI������������������������������������������

  • ������������������������vue.config.js������������������������������

    • publicPath���������������������������������������
    • outputDir������������������������������������
    • pages���������������������������������
    • devServer���������������������������������������������������������������������
    • css���������������������CSS������������������
  • 7. ������������

    • ������������������������������vue.config.js���������
    • ������package.json������ slavery.clear���include������������������������������������������
    • ������npm run serve������������������������������������������������������������������������

    ������������������������������������������������������������������������������������������

  • ������Vue CLI���������������������vue.config.js���������������������
  • ������������������������������������vue CLI���������������������������������������������������������������
  • ������������������������������������������������Vue-CLI2���������Vue-CLI4���������������������������������������������������������������������������������������������������������������������������������������������

    上一篇:【Android项目实战 | 从零开始写app(14)】实现用户中心模块清除token退出登录 & 信息修改等功能
    下一篇:【Android项目实战 | 从零开始写app(11)】实现app首页功能&九宫格服务分类&热门推荐&新闻列表

    发表评论

    最新留言

    做的很好,不错不错
    [***.243.131.199]2025年04月24日 16时00分54秒