1.项目当中执行,安装webpackbar

cnpm i webpackbar --save-dev

2.vuecli3.x中配置vue.config.js,引入webpackbar

const WebpackBar = require("webpackbar");

3.configureWebpack下配置plugins,

new WebpackBar({

name: `董xx的项目`,

color: "#f40",

}),

4.在项目执行npm run build打包项目 或者 修改项目代码热重载就会出现编译的进度条提示,如下图所示,能给开发人员带来良好的开发体验。

5.vue.config.js配置如下:

"use strict";

const path = require("path");

const { title, abbreviation, devPort } = require("./src/config/settings");

const pkg = require("./package.json");

const Webpack = require("webpack");

const WebpackBar = require("webpackbar");

const FileManagerPlugin = require("filemanager-webpack-plugin");

const date = require("dayjs")().format("YYYY_M_D"); //"2020_6_11"

const time = require("dayjs")().format("YYYY-M-D HH:mm:ss"); //"2020-6-11 15:00:24"

const CompressionWebpackPlugin = require("compression-webpack-plugin");

const productionGzipExtensions = ["html", "js", "css", "svg"];

function resolve(dir) {

return path.join(__dirname, dir);

}

function mockServer() {

if (process.env.NODE_ENV === "development") {

const mockServer = require("./mock/mock-server.js");

return mockServer;

} else {

return "";

}

}

const name = title || "vue-admin-beautiful";

module.exports = {

publicPath: "",

assetsDir: "static",

outputDir: "dist",

lintOnSave: true,

transpileDependencies: ["vue-echarts", "resize-detector"],

devServer: {

hot: true,

port: devPort,

open: true,

noInfo: false,

overlay: {

warnings: true,

errors: true,

},

after: mockServer(),

},

configureWebpack(config) {

return {

name: name,

resolve: {

alias: {

"@": resolve("src"),

"^": resolve("src/components"),

},

},

plugins: [

new Webpack.ProvidePlugin({

$: "jquery",

jQuery: "jquery",

"windows.jQuery": "jquery",

echarts: "echarts",

"window.echarts": "echarts",

maptalks: "maptalks",

"window.maptalks": "maptalks",

}),

new Webpack.DefinePlugin({

"process.env.VUE_APP_UPDATE_TIME": "'" + time + "'",

}),

new WebpackBar({

name: `董xx的项目`,

color: "#f40",

}),

],

};

},

chainWebpack(config) {

config.plugins.delete("preload");

config.plugins.delete("prefetch");

config.resolve.symlinks(true);

config.module

.rule("svg")

.exclude.add(resolve("src/remixIcon"))

.add(resolve("src/colorfulIcon"))

.end();

config.module

.rule("remixIcon")

.test(/\.svg$/)

.include.add(resolve("src/remixIcon"))

.end()

.use("svg-sprite-loader")

.loader("svg-sprite-loader")

.options({ symbolId: "remix-icon-[name]" })

.end();

config.module

.rule("colorfulIcon")

.test(/\.svg$/)

.include.add(resolve("src/colorfulIcon"))

.end()

.use("svg-sprite-loader")

.loader("svg-sprite-loader")

.options({ symbolId: "colorful-icon-[name]" })

.end();

config.module

.rule("vue")

.use("vue-loader")

.loader("vue-loader")

.tap((options) => {

options.compilerOptions.preserveWhitespace = true;

return options;

})

.end();

config.when(process.env.NODE_ENV === "development", (config) => {

config.devtool("cheap-module-eval-source-map");

});

config.when(process.env.NODE_ENV !== "development", (config) => {

config.performance.set("hints", false);

config.devtool("none");

config

.plugin("ScriptExtHtmlWebpackPlugin")

.after("html")

.use("script-ext-html-Webpack-plugin", [{ inline: /runtime\..*\.js$/ }])

.end();

config.optimization.splitChunks({

chunks: "all",

cacheGroups: {

libs: {

name: "chunk-libs",

test: /[\\/]node_modules[\\/]/,

priority: 10,

chunks: "initial",

},

elementUI: {

name: "chunk-elementUI",

priority: 20,

test: /[\\/]node_modules[\\/]_?element-ui(.*)/,

},

commons: {

name: "chunk-commons",

test: resolve("src/components"),

minChunks: 3,

priority: 5,

reuseExistingChunk: true,

},

},

});

config.optimization.runtimeChunk("single");

config

.plugin("banner")

.use(Webpack.BannerPlugin, [

` \u57fa\u4e8e\u0076\u0075\u0065\u002d\u0061\u0064\u006d\u0069\u006e\u002d\u0062\u0065\u0061\u0075\u0074\u0069\u0066\u0075\u006c\u6784\u5efa \n \u0063\u006f\u0070\u0079\u0072\u0069\u0067\u0068\u0074\u003a\u0020\u0063\u0068\u0075\u007a\u0068\u0069\u0078\u0069\u006e\u0020\u0031\u0032\u0030\u0034\u0035\u0030\u0035\u0030\u0035\u0036\u0040\u0071\u0071\u002e\u0063\u006f\u006d \n \u0074\u0069\u006d\u0065\u003a ${time}`,

])

.end();

});

config

.plugin("compression")

.use(CompressionWebpackPlugin, [

{

filename: "[path].gz[query]",

algorithm: "gzip",

test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),

threshold: 8192,

minRatio: 0.8,

},

])

.end();

config.when(process.env.NODE_ENV === "production", (config) => {

config

.plugin("fileManager")

.use(FileManagerPlugin, [

{

onEnd: {

delete: ["./dist/video", "./dist/data"],

archive: [

{

source: "./dist",

destination: `./dist/${abbreviation}_dist_${date}.7z`,

},

],

},

},

])

.end();

});

},

runtimeCompiler: true,

productionSourceMap: false,

css: {

requireModuleExtension: true,

sourceMap: true,

loaderOptions: {

scss: {

prependData: '@import "~@/styles/variables.scss";',

},

},

},

};

nuxt webpack配置css,vuecli或nuxt用Webpack的优雅ProgressBar(webpackBar)相关推荐

  1. nuxt webpack配置css,nuxt笔记

    初始化: vue init nuxt/starter  (类似 vue init webpack) 配置IP和端口: 配置全局CSS 配置webpack的loader nuxt路由配置和传参 Nuxt ...

  2. nuxt webpack配置css,基于nuxt通过webpack配置ant-Design-vue的主题切换配置

    1.首先在nuxt官网初始化好基于ant-Design-vue的项目, 安装.png 选择ant-Design-vue UI框架 2.初始化完成,查找package.json是否安装了less与les ...

  3. vue-cli中的webpack配置

    编辑模式下显示正常,打开的时候不知道为啥排版有问题. segementfalut链接在这里 版本号 vue-cli 2.8.1 (终端通过vue -V 可查看) vue 2.2.2 webpack 2 ...

  4. webpack打包css image,webpack 打包CSS 引入图片

    加载css 安装style-loader, css-loader npm install style-loader css-loader --save-dev 配置webpack.config.js文 ...

  5. 新手向webpack配置

    webpack配置 前言 本人小白一枚,每次使用webpack都要好一番搜索加CV.今天突然心血来潮,准备去网上搜索一番,整理一下webpack的简单使用,避免每次使用都要花费半天时间去百度,一劳永逸 ...

  6. 基于Vue-cli和Vux的webpack配置

    基于vue-cli配置 然后使用vux的webpack配置 npm i vue-cli -g // 如果还没安装 vue init airyland/vux2 projectPathcd projec ...

  7. vue-cli webpack配置分析 - chenBright - SegmentFault 思否

    相信vue使用者对vue-cli都不会陌生,甚至可以说,很熟悉了,但对其webpack的配置可能知之甚少吧. 过完年回来后,我接手了公司的新项目.新项目是一个spa.很自然,我就想到了vue-cli脚 ...

  8. vue-cli脚手架中webpack配置基础文件详解

    一.前言 vue-cli是构建vue单页应用的脚手架,输入一串指定的命令行从而自动生成vue.js+wepack的项目模板.这其中webpack发挥了很大的作用,它使得我们的代码模块化,引入一些插件帮 ...

  9. 基于vue-cli的webpack配置优化

    基于vue-cli优化的webpack配置 大概分为以下几点 通过 externals 配置来提取常用库,引用外链 配置CommonsChunkPlugin提取公用代码 (vue-cli已做) 善用a ...

最新文章

  1. 仅需6步,教你轻易撕掉app开发框架的神秘面纱(2):MVP比MVC更好吗
  2. 小白兔写话_聪明的小白兔看图写话
  3. 2、Android应用程序基本特性
  4. 机器能否拥有像人类一样的意识?Science长文综述解读
  5. CentOS_7 MongoDb安装使用
  6. Linux 系统应用编程——进程间通信(下)
  7. 阿里云:构建全球企业内外安全网络最佳实践
  8. SQL Server 2005 Service Broker 初探 [摘抄]
  9. 未打清分标识处理方式
  10. C++中menset用法
  11. C#LINQ方法操作-Max求数组集合中最大值
  12. oracle in 文件太多,oracle 目录下文件太多,直接rm 报错,替代方法
  13. 转载--程序员最喜欢的技术书大都出自这 20 家出版社
  14. LAMP让开放源代码软件更安全 PHP是例外
  15. SpringBoot搭建简单留言板项目
  16. 数据中台到底是什么?
  17. 分享20个增长黑客经典案例。
  18. VUE3 之 生命周期函数
  19. nginx长连接——keepalive
  20. 民数记研读3——于宏洁

热门文章

  1. hiveserver2总是启动不起来
  2. dell 如何给raid分区_用U盘启动盘给Dell服务器装系统找不到RAID阵列解决办法
  3. 从0开始配置Win环境下VScode (VScode For C/C++)
  4. getmodifiers java_getModifiers()方法如何计算多个修饰符的值?
  5. js去掉第一个换行符_通过异步迭代简化Node.js流程
  6. js文件中使用jstl或者其他标签
  7. leetcode题解102-二叉树的层序遍历
  8. iOS 8 UI布局 AutoLayout及SizeClass(二)
  9. 使用Flexible实现H5页面的终端适配
  10. Convert Sorted Array to Binary Search Tree With Minimal Height