vue webpak版本 查看_vue升级webpack版本到webpack4

目录

用vue来实验下, 目的是把webpack3升级至^4.0

更新思路是

先更新

看是否废弃掉了

yarn global add @vue/cli-init 

vue init webpack hello_vue

20190807165906.png

cd hello_vue 

npm start

需要先验证工程是正确的, 可以运行后去看下webpack版本

20190807170516.png

发现是3.6

npm install webpack@latest -D

npm install webpack-dev-server@latest -D

npm i webpack-cli@latest -D

npm i html-webpack-plugin@latest -D

npm i eslint-loader@latest -D

npm i vue-loader@latest -D

npm i css-loader@latest -D

npm i postcss-loader@latest -D

npm start

20190807170710.png

根据npm start 报错来修改升级

然后发现

20190808013118.png

再去写入配置文件

20190808013937.png

配置和完成后就ok了

20190808014310.png

再去配置mode

20190808014636.png

npm run build

打包看下有没有错

20190808015206.png

20190808015314.png

去官方文档把对应的代码加到配置和pro中去

optimization: {

    splitChunks: {

      chunks: 'async',

      minSize: 30000,

      maxSize: 0,

      minChunks: 1,

      maxAsyncRequests: 5,

      maxInitialRequests: 3,

      automaticNameDelimiter: '~',

      automaticNameMaxLength: 30,

      name: true,

      cacheGroups: {

        vendors: {

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

          priority: -10

        },

        default: {

          minChunks: 2,

          priority: -20,

          reuseExistingChunk: true

        }

      }

    }

  }

20190808015603.png

注意有三个地方都要注释掉

然后发现报错:

Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead

npm install extract-text-webpack-plugin@next -D

next代表还没正式发布的版本, 是在latest之后的

然后就是报错

Error: Path variable [contenthash] not implemented in this context: static/css/[name].[contenthash].css

20190808021002.png

20190808021137.png

这样就正式更新至webpack4完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值