亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue項目打包:修改dist文件名方式

 更新時間:2022年12月05日 09:38:32   作者:藍胖子的多啦A夢  
這篇文章主要介紹了vue項目打包:修改dist文件名方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

vue項目打包:修改dist文件名

vue.config.js

?// 輸出文件目錄(默認dist)
? ?outputDir: 'smf',
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')

function resolve(dir) {
  return path.join(__dirname, dir)
}

const name = defaultSettings.title // 網(wǎng)址標題
//const port = 8013 // 端口配置
const port = 8000 // 端口配置
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
  // hash 模式下可使用
  // publicPath: process.env.NODE_ENV === 'development' ? '/' : './',
  publicPath: './',
  outputDir: 'smf',
  assetsDir: 'static',
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    port: port,
    open: false,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '/api': {
        target: process.env.VUE_APP_BASE_API,
        changeOrigin: true,
        pathRewrite: {
          '^/api': 'api'
        }
      },
      '/auth': {
        target: process.env.VUE_APP_BASE_API,
        changeOrigin: true,
        pathRewrite: {
          '^/auth': 'auth'
        }
      }
    }
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    name: name,
    resolve: {
      alias: {
        '@': resolve('src'),
        '@crud': resolve('src/components/Crud')
      }
    }
  },
  chainWebpack(config) {
    config.plugins.delete('preload') // TODO: need test
    config.plugins.delete('prefetch') // TODO: need test

    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]',

      })

      .end()

    // set preserveWhitespace
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .tap(options => {
        options.compilerOptions.preserveWhitespace = true
        return options
      })
      .end()

    config
      // https://webpack.js.org/configuration/devtool/#development
      .when(process.env.NODE_ENV === 'development',
        // config => config.devtool('cheap-source-map')
        config => config
      )

    config
      .when(process.env.NODE_ENV !== 'development',
        config => {
          config
            .plugin('ScriptExtHtmlWebpackPlugin')
            .after('html')
            .use('script-ext-html-webpack-plugin', [{
              // `runtime` must same as runtimeChunk name. default is `runtime`
              inline: /runtime\..*\.js$/
            }])
            .end()
          config
            .optimization.splitChunks({
              chunks: 'all',
              cacheGroups: {
                libs: {
                  name: 'chunk-libs',
                  test: /[\\/]node_modules[\\/]/,
                  priority: 10,
                  chunks: 'initial' // only package third parties that are initially dependent
                },
                elementUI: {
                  name: 'chunk-elementUI', // split elementUI into a single package
                  priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
                  test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
                },
                commons: {
                  name: 'chunk-commons',
                  test: resolve('src/components'), // can customize your rules
                  minChunks: 3, //  minimum common number
                  priority: 5,
                  reuseExistingChunk: true
                }
              }
            })
          config.optimization.runtimeChunk('single')
        }
      )
  },
  transpileDependencies: [
    'vue-echarts',
    'resize-detector'
  ]
}

修改vue打包后的默認文件名

問題:因為我想在我的服務器上部署兩個vue項目,但是vue打包后默認的項目名是dist,這樣子就跟我上一個vue項目沖突了。因此查了一下資料。

解決方案

進入config ⇒ index.js,在build中將dist關鍵字改成其他名稱即可。

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • VUE注冊全局組件和局部組件過程解析

    VUE注冊全局組件和局部組件過程解析

    這篇文章主要介紹了VUE注冊全局組件和局部組件過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-10-10
  • nuxt.js中間件實現(xiàn)攔截權限判斷的方法

    nuxt.js中間件實現(xiàn)攔截權限判斷的方法

    這篇文章主要介紹了nuxt.js中間件實現(xiàn)攔截權限判斷的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • 如何在 ant 的table中實現(xiàn)圖片的渲染操作

    如何在 ant 的table中實現(xiàn)圖片的渲染操作

    這篇文章主要介紹了如何在 ant 的table中實現(xiàn)圖片的渲染操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10
  • VUE的數(shù)據(jù)代理與事件詳解

    VUE的數(shù)據(jù)代理與事件詳解

    這篇文章主要為大家介紹了VUE的數(shù)據(jù)代理與事件,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-11-11
  • 基于Ant-design-vue的Modal彈窗 封裝 命令式與Hooks用法

    基于Ant-design-vue的Modal彈窗 封裝 命令式與Hooks用法

    這篇文章主要給大家介紹了基于Ant-design-vue的Modal彈窗封裝命令式與Hooks用法,文中有詳細的代碼示例,具有一定的參考價值,感興趣的同學可以借鑒閱讀
    2023-06-06
  • vue中引用swiper輪播插件的教程詳解

    vue中引用swiper輪播插件的教程詳解

    這篇文章主要介紹了vue中引用swiper輪播插件的方法,在需要使用swiper的組件里引入swiper,swiper的初始化放在mounted里。具體實例代碼大家跟隨腳本之家小編一起看看吧
    2018-08-08
  • Vue動態(tài)組件實例解析

    Vue動態(tài)組件實例解析

    讓多個組件使用同一個掛載點,并動態(tài)切換,這就是動態(tài)組件。這篇文章主要介紹了Vue動態(tài)組件 ,需要的朋友可以參考下
    2017-08-08
  • vue組件代碼分塊和懶加載講解

    vue組件代碼分塊和懶加載講解

    這篇文章主要介紹了vue組件代碼分塊和懶加載講解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • 詳解.vue文件中監(jiān)聽input輸入事件(oninput)

    詳解.vue文件中監(jiān)聽input輸入事件(oninput)

    本篇文章主要介紹了詳解.vue文件中監(jiān)聽input輸入事件(oninput),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • Vue 用Vant實現(xiàn)時間選擇器的示例代碼

    Vue 用Vant實現(xiàn)時間選擇器的示例代碼

    這篇文章主要介紹了Vue 用Vant實現(xiàn)時間選擇器的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-10-10

最新評論