配置 vue.config.js & index.html

vue.config.js配置压缩dist vuecli配置 不看不知道一看吓一跳 学习vue.config.js刻不容缓 贴出我的config const isProduction = process.env.NODE_ENV === 'production'; const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const cdn = { css: ["http... 阅读详情

配置两个文件:

  1. vue.config.js 配置 cdn & zip
  2. public/index.html 配置

– stylelint 可配置样式格式输出

1. vue.config.js 配置(可直接复制)

出处:https://c.lanmit.com/Webqianduan/JavaScript/55401.html

注意事项:
  • 用 jsdelivr 代替 bootcdn
  • 安装 cnpm install compression-webpack-plugin --save-dev
const path = require('path')
const resolve = (dir) => path.resolve(__dirname, dir);
// 是否为生产环境
const isProduction = process.env.NODE_ENV !== 'development'
console.log('isProductionisProduction', process.env.NODE_ENV)
// gzip压缩
const CompressionWebpackPlugin = require('compression-webpack-plugin')


const Proxy =  {
  '/api': {
    // 代理地址
    target: 'http://172.16.8.44:8086',
    changeOrigin: true, // 是否跨域
    secure: false,
    pathRewrite: {
      '^/api': '/api/ctrl', //测试环境
      // '/api': '', //需要rewrite重写的, //本地联调
    }
  }
}

const cdn = {
  // 忽略打包的第三方库
  externals: {
    vue: 'Vue',
    vuex: 'Vuex',
    'vue-router': 'VueRouter',
    axios: 'axios',
    'element-ui': 'ELEMENT',
  },

  // 通过cdn方式使用
  js: [
    'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js',
    'https://cdn.jsdelivr.net/npm/vue-router@3.2.0/dist/vue-router.min.js',
    'https://cdn.jsdelivr.net/npm/vuex@3.4.0/dist/vuex.min.js',
    'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js',
    'https://cdn.jsdelivr.net/npm/moment@2.26.0/moment.min.js',
    'https://cdn.jsdelivr.net/npm/element-ui@2.13.2/lib/index.js'
  ],
  css: [
    'https://cdn.jsdelivr.net/npm/element-ui@2.9.2/lib/theme-chalk/index.css'
  ]
}

module.exports = {
  publicPath: '/',
  outputDir: 'dist',
  lintOnSave: false,
  runtimeCompiler: false,     //是否使用包含运行时编译器的 Vue 构建版本
  productionSourceMap: false, //生产环境是否生成 sourceMap 文件
  integrity: false,           //生成的 HTML 中的 <link rel="stylesheet"> 和 <script> 标签上启用 Subresource Integrity (SRI)
  // webpack相关配置
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('common', resolve('src/common'))
      .set('assets', resolve('src/assets'))
      .set('router', 'src/router')
      .set('store', 'src/store')
      .set('components', resolve('src/components'))
      .set('views', resolve('src/views'))
      .set('i18n', resolve('src/i18n'))
      .set('config', resolve('src/config'))

    // 移除 prefetch 插件
    config.plugins.delete('prefetch-index');
    // 移除 preload 插件,避免加载多余的资源
    config.plugins.delete('preload-index');
    // 配置cdn引入
    config.plugin('html').tap((args) => {
      args[0].cdn = cdn;
      return args
    })
  },
  configureWebpack: config => {
    // 忽略打包配置
    config.externals = cdn.externals
    if (isProduction) {
      // 生产环境
      //gzip压缩
      const productionGzipExtensions = ['html', 'js', 'css']
      config.plugins.push(
        new CompressionWebpackPlugin({
          filename: '[path].gz[query]',
          algorithm: 'gzip',
          // eslint-disable-next-line no-useless-escape
          test: new RegExp('\.(' + productionGzipExtensions.join('|') + ')$'),
          threshold: 10240, // 只有大小大于该值的资源会被处理 10240
          minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
          deleteOriginalAssets: false, // 删除原文件
        })
      )
      // 公共代码抽离
      config.optimization = {
        // 分割代码块 chunk
        splitChunks: {
          cacheGroups: {
            //公用模块抽离
            common: {
              chunks: 'initial',
              minSize: 0, //大于0个字节
              minChunks: 2, //抽离公共代码时,这个代码块最小被引用的次数
            },
            //第三方库抽离
            vendor: {
              priority: 1, //权重
              test: /node_modules/,
              chunks: 'initial',
              minSize: 0, //大于0个字节
              minChunks: 2, //在分割之前,这个代码块最小应该被引用的次数
            },
          }
        }
      }
    } 
    else {
      // 开发环境
      // config.mode = 'development';
    }
  },
  devServer: {
    overlay: {
      warnings: false,
      errors: false,
    },
    open: true,
    host: '0.0.0.0',
    port: 8701,
    https: false,
    hotOnly: true,
    proxy: Proxy
  },
  css: {
    extract: true,
    sourceMap: false,
    // css预设器配置项
    loaderOptions: {
      sass: {
        prependData: `@import "@/common/style/_variable.scss";`
      }
    },
  },
  // 第三方插件配置 
  pluginOptions: {}
}

2. index.html 配置(可直接复制)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta http-equiv="x-dns-prefetch-control" content="on"/>
    <link rel="dns-prefetch" href="//cdn.jsdelivr.net">

    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title></title>

    <script src="libs/flexible.js"></script>

    <% for (var i in
    htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
    <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
    <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
    <% } %>
  </head>
  <body>
    <noscript>
      <strong>很抱歉,没有启用JavaScript, 本服务无法正常工作!</strong>
    </noscript>
    <div id="app"></div>
    <% for (var i in
    htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
    <script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
    <% } %>
  </body>
</html>

— end

解决vue-cli2和vue-cli3项目分别打包后dist文件中index.html出现空白 是不是遇到过在vue项目在开发环境下一切正常,但在npm run build之后,打开dist文件中的index.html页面却是一片空白,打开控制台发现报错:Failed to load resource: net::ERR_FILE_NOT_FOUND 出现这个问题的话,需要查看自己使用的是vue-cli2还是vue-cli3,他们处理方式不一样。 一.vue-cli2处理方式: 项目中找到config/index.js文件,将assetPublicPath的路径改为“./”即可。 二. 阅读详情

相关推荐

如何在Vue打包后修改文件中的接口地址配置

然而,当我们将Vue项目打包部署到生产环境时,需要修改打包后的文件中的接口地址,以连接到正确的服务器。接下来,我们需要在打包后的文件中修改接口地址配置。需要注意的是,每次打包Vue项目时,都需要进行上述的修改步骤。因此,在开发过程中,我们可以使用环境变量或配置文件来动态地设置接口地址,以便在不同的环境中自动切换接口地址。接下来,将修改后的文件和其他打包后的静态文件部署到生产环境的服务器上。通过以上步骤,我们成功地修改了Vue打包后文件中的接口地址配置。在这个文件中,我们需要查找并修改包含接口地址的代码。

PixelInk的博客 1828

vue.config.js 常用配置

官方文档 https://cli.vuejs.org/zh/config 说明 vue-cli3将webpack的基础配置全部内嵌了,统一使用: vue.config.js 当然,也可以单独创建,再引用 module.exports = { publicPath:'./', // 公共,基本路径 // 输出文件目录,不同的环境打不同包名 outputDir: process.env.NODE_ENV === "development" ? 'devdist' : 'd

南北极之间 1693

【SOC估计】基于EKF与二阶RC等效电路模型的锂电池SOC在线估计算法实现与仿真分析

本文详细介绍了基于扩展卡尔曼滤波(EKF)与二阶RC等效电路模型的锂电池SOC在线估计算法。通过Matlab仿真分析,展示了该算法如何实现高精度SOC估计,相比传统方法显著提升估计精度与鲁棒性,适用于电动汽车、储能系统等关键领域。

1092

vue前端开发中,通过vue.config.js配置和nginx配置,实现多个入口文件的实现方法

由于vue为单页面项目,通过控制组件局部渲染,main.js是整个项目唯一的入口,整个项目都在一个index.html外壳中。若项目过大,会造成单页面负载过重;同时,多页面利于模块独立部署。

在这里,我乐于倾囊相授,分享我的技术心得、项目实战经验、技术技巧。希望能够惠及更多的开发者,助力大家在技术的海洋中扬帆远航。 4608

新手必看:如何用T265和ROS实现无人机室内精准定位(附PX4参数配置)

本文详细介绍了如何使用Intel Realsense T265和ROS实现无人机室内精准定位,包括硬件准备、ROS数据流架构设计、PX4参数配置及系统验证。特别针对视觉SLAM技术在室内环境中的应用,提供了从零搭建到进阶优化的全流程解析,适合无人机开发新手快速上手。

weixin_30642561的博客 404

OpenVox 8FXO板卡驱动安装记录

OpenVox A800P和A1200P的板卡驱动安装及问题解决方法

clliu的专栏 2463

如何搭建一个完整的Vue3.0 + ts 的项目

如何搭建一个完整的Vue3.0 + ts 的项目 相信9月18日尤大大的关于Vue3.0的发表演讲大家一定有所关注,现在Vue3.0 也已经进入RC阶段(最终产品的候选版本,如果没有问题则可发布成为正式版本)。所以Vue3.0的学习是我们必然的趋势,今天,主要分享一下Vue3.0的详细搭建过程,希望可以为初入Vue3的小伙伴有所帮助。 我们现在开始进入今天的主题啦~~ 一、安装 1. 安装nodejs 此处提供nodejs下载地址:https://nodejs.org/zh-cn/dow..

sinat_28371057的博客 5217

【Unity动画系统】详解Root Motion动画在Unity中的应用(一)

什么时候勾选Bake into pose,当不希望动画带动游戏对象旋转时。在旋转的动画中一般是不用勾选的,因为就需要用它来带动我们的角色对象旋转。但在比如前进、后退、待机等动画来说,我们就可以勾选这里,以避免因动画文件本身的瑕疵而给我们带来的旋转。loop match:代表了这个动画在角度上的吻合度。如果这个动画在播放中转角过大,那么就会显示红色,告诉我们如果勾选bake into pose,则会带来不好的效果。

weixin_60154963的博客 6802

关于VUE 配置文件config详解内容

// const path = require('path'); module.exports = { /** 区分打包环境与开发环境 * process.env.NODE_ENV==='production' (打包环境) * process.env.NODE_ENV==='development' (开发环境) * baseUrl: pr...

weixin_30344131的博客 1551

STM32 IIC电量计LTC2944

LTC2944是一款电池电量计,设计用于端电压为3.6V至60V的多节电池。它测量电池充电和放电、电池电压、电流和自身温度。精密模拟库仑计数器通过电池正极端子与负载或充电器之间的检测电阻器对电流进行积分。电池电压、电池电流和硅温度由内部ADC测量。

baidu_34971492的博客 3160

I2C通信——时序图

本文用逻辑分析仪抓取主机I2C通信的时序图,抓取的过程是读某个寄存器的值。

weixin_43772611的博客 7353

深入解析vue中config/index.js

详解vue中config下index.js的每一行默认配置 //vue cli官方地址: https://cli.vuejs.org/zh/config/ module.exports = { //部署应用包时的基本 URL。 //Type: string, //默认: '/' publicPath: './', //当运行 vue-cli-service...

一只程序猿 3056

Codex入门24-效率倍增秘籍(终极总结:10个让你开发速度翻倍的Codex高级技巧)

专栏收官之作!经过前23篇的系统学习,你已经掌握了 Codex CLI 的核心用法。本文浓缩10个实战验证的高级技巧:管道化提示词将复杂任务拆成递进指令链,模板化 SKILL.md 打造个人技能库,Shell 别名让操作快如闪电,多模型切换省钱又高效……这不是理论课,每个技巧都配有可直接运行的代码。掌握全部10招,构建你的 AI 开发工作流闭环,让开发速度真正翻倍!

yueyeguzhuo的专栏 188

vue项目中,main.js,App.vue,index.html的关系

一、main.js是我们的入口文件,主要作用是初始化vue实例,并引入所需要的插件 import Vue from 'vue' import App from './App' import router from './router' Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '...

郑金旭的博客 3964

Cesium 场景特效之【全球海洋】GL2兼容版

Cesium 场景特效之【全球海洋】GL2兼容版

喜欢钻研前端和分享技术 1272

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = &quot;R. B. Palm&quot;, title = &quot;Prediction as a candidate for learning deep hierarchical models of data&quot;, year = &quot;2012&quot;,}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er&lt;0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er &lt; 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free &quot;Bitdeli Badge&quot;)

vue 指定index.html,[Vue CLI 3] 配置解析之 indexPath

原标题:[Vue CLI 3] 配置解析之 indexPath 在 vue.config.js 配置中有一个 indexPath 的配置,我们先看看它有什么用?用来 指定 index.html 最终生成的路径(相对于 outputDir)先看看它的默认值:在文件 @vue/cli-service/lib/options.js 中indexPath: joi.string()默认值:indexPat...

weixin_36008052的博客 3470

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

vue.config.js的简单配置

vue.config.js的配置 const path = require('path') const CompressionWebpackPlugin = require('compression-webpack-plugin') // alias function resolve(dir) { return path.join(__dirname, dir) } // 转为CND外链方式...

weixin_39347470的博客 536

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Vue build 打包和部分vue-config-js配置

vue 打包 当我们使用vue写好项目后我们需要将项目进行打包成html项目,使用一下命令可以打包项目。 npm run build 在当前目录下输入打包命令,等待打包完成后在根目录生成一个dist的文件夹,里面是html页面和css,js,img文件夹。 -- dist -- css -- js -- img -- index.html 当然这个html项目我们无法通过双击的形式打开,我们需要创建一个服务才能运行此项目。 vue-config-js配置 在vue项目里创建vue.con

王飞 1万+

【vue】index.html main.js app.vue index.js怎么结合的? 怎么打包的?

怎么结合的: &nbsp; 一、启动项目 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;第一步:cmd进入项目文件里,运行npm run dev &nbsp;启动项目 &nbsp; &nbsp;这里说明启动端口号是8080 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;第二步:往页面输...

学习笔记666 938

vue项目中app.vue 、main.js和 index.html的关联

1. main.js是入口文件,主要作用是初始化vue实例并使用需要的插件。 2. App.vue是主组件,所有页面都是在App.vue下进行切换的。 3. main.js中的根实例会挂载到index.html中的&lt;div id="app"&gt; 4. index.html文件入口 5. src放置组件和入口文件 6. node_modules为依赖...

kangkang_style的博客 2030

vue项目打包后index.html页面空白怎么办?

vue项目打包成功后生成dist文件,在dist文件里的index.html页面打开是空白的,并且控制台报错: 报错的原因在于index.html页面里引入文件的路径有问题 我们可以在官网上找到vue cli的配置参考 解决方案:在vue根目录下创建vue.config.js文件在里面 module.exports = { publicPath: './', }; ...

xixi的博客 1909

vue修改入口文件名字_vue.config.js配置

// Vue.config.js 配置选项module.exports = {// 选项// 基本路径publicPath: "./",// 构建时的输出目录outputDir: "dist",// 放置静态资源的目录assetsDir: "static",// html 的输出路径indexPath: "index.html",//文件名哈希filenameHashing: true,/...

weixin_30932183的博客 3045

vue-cli3 没有config.js文件的解决办法

之前遇到vue打包后白屏,解决办法都是修改config文件,cli3没有该文件需要手动创建。 白屏的问题,打包后的index.html中JS都是根目录的,所有打包后不放根目录找不到其他js文件。可以通过新建并配置config.js来完成 官方vue-cli 3,精简很多文件,其中包括没有了cli2中的config目录,所以需要更改之前cli2中config中相关的配置文件, 需要在cli3项目根目录下新建文件vue.config.js来写,注意不是src目录,是根目录 module.exp.

baok1592的专栏 4093

通过cdn和vue.config.js配置来优化vue-cli3.0打包体积

1.再vue.config.js中设置 module.exports = { chainWebpack: config =&gt; { // 发布模式 config.when(process.env.NODE_ENV === 'production', config =&gt; { config.entry('app').clear().add('./src/main-prod.js') config.set('externals', { vu

weixin_43837268的博客 4488

最快捷的两种方案彻底解决:vue打包后dist目录下的index.html网页显示空白的问题

📢:解决vue 打包后dist 目录下index.html 页面空白的问题。两种方案快速解决......

AI布道师丨波仔椿 1万+

详解 Vue 目录及配置文件之 config 目录

本人是个菜鸡,多处借鉴学习,综合整理出来这篇比较全面的 config 中配置文件说明。

Demo_Null 1万+
上一篇: 公众号本地调试,域名配置思路
下一篇: 将本地端口映射子域名
萝卜芹菜芽
博客等级 码龄10年 27粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值