【问题标题】:Config webpack-bundle-tracker from vue.config.js to quasar.conf.js将 webpack-bundle-tracker 从 vue.config.js 配置到 quasar.conf.js
【发布时间】:2021-01-08 02:00:38
【问题描述】:

我有一个使用此配置运行的 Vuejs 应用程序:

const BundleTracker = require("webpack-bundle-tracker");

module.exports = {
// on Windows you might want to set publicPath: "http://127.0.0.1:8080/" 
 publicPath: "http://0.0.0.0:8080/", 
 outputDir: './dist/', 

 chainWebpack: config => {

    config
        .plugin('BundleTracker')
        .use(BundleTracker, [{filename: './webpack-stats.json'}])

    config.output
        .filename('bundle.js')

    config.optimization
        .splitChunks(false)

    config.resolve.alias
        .set('__STATIC__', 'static')

    config.devServer
        // the first 3 lines of the following code have been added to the configuration
        .public('http://127.0.0.1:8080')    
        .host('127.0.0.1')    
        .port(8080)
        .hotOnly(true)
        .watchOptions({poll: 1000})
        .https(false)
        .disableHostCheck(true)
        .headers({"Access-Control-Allow-Origin": ["\*"]})

},
};

文件 webpack-stats.json 是这样的:

{"status":"done","publicPath":"http://0.0.0.0:8080/","chunks":{"app":[{"name":"bundle.js","publicPath":"http://0.0.0.0:8080/bundle.js","path":"/home/me/myproject/frontend/dist/bundle.js"}]}}

关于如何为 quasar.conf.js 翻译此内容的任何提示?

【问题讨论】:

    标签: vue.js quasar-framework webpack-bundle


    【解决方案1】:

    在构建键里面放这一行

    build: {
      vueRouterMode: 'hash', // available values: 'hash', 'history'
      chainWebpack: config => {
        config
          .output
          .publicPath('http://localhost:8080/')
        config
          .plugin('BundleTracker')
          .use(BundleTracker, [{ filename: './webpack-stats.json' }])
    
        config.output
          .filename('bundle.js')
    
        config.optimization
          .splitChunks(false)
    
        config.resolve.alias
          .set('__STATIC__', 'static')
    
        config.devServer
          .public('http://127.0.0.1:8080')
          .host('127.0.0.1')
          .port(8080)
          .hotOnly(true)
          .watchOptions({ poll: 1000 })
          .https(false)
          .disableHostCheck(true)
          .headers({ "Access-Control-Allow-Origin": ["\*"] })
      },
    }
    

    为 in devServer 键添加此行

    headers: {
        'Access-Control-Allow-Origin':  '*'
    }
    

    【讨论】:

      猜你喜欢
      • 2020-10-14
      • 2021-08-28
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 2021-05-30
      • 2020-05-29
      • 2019-11-10
      • 1970-01-01
      相关资源
      最近更新 更多