国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

babel7.x和webpack4.x配置vue項目的方法步驟

2024-05-06 15:39:37
字體:
來源:轉載
供稿:網友

很偶然的今天想開個自己的小項目,記錄一下最近項目工程上實現的一個小交互。按照之前運行非常流暢的配置走一遍,打包遇到各種坑。只好根據命令行的報錯逐個排查,發現babel升級了一個大版本,已經到7.x了。看來每日沉迷項目,已經跟不上節奏了。這里記錄一下遇到的問題以及解決方案。

1.webpack 4.x 插件 extract-text-webpack-plugin

(node:2628) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` insteadi 「wds」: Project is running at http://localhost:8300/i 「wds」: webpack output is served from /i 「wds」: Content not from webpack is served from F:/private/plugin-insert/distF:/private/plugin-insert/node_modules/webpack/lib/Chunk.js:838        throw new Error(        ^Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead  at Chunk.get (F:/private/plugin-insert/node_modules/webpack/lib/Chunk.js:838:9)  at F:/private/plugin-insert/node_modules/extract-text-webpack-plugin/dist/index.js:176:48  at Array.forEach (<anonymous>)  at F:/private/plugin-insert/node_modules/extract-text-webpack-plugin/dist/index.js:171:18  at AsyncSeriesHook.eval [as callAsync] (eval at create (F:/private/plugin-insert/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)  at AsyncSeriesHook.lazyCompileHook (F:/private/plugin-insert/node_modules/tapable/lib/Hook.js:154:20)  at Compilation.seal (F:/private/plugin-insert/node_modules/webpack/lib/Compilation.js:1231:27)  at hooks.make.callAsync.err (F:/private/plugin-insert/node_modules/webpack/lib/Compiler.js:541:17)  at _done (eval at create (F:/private/plugin-insert/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:9:1)  at _err1 (eval at create (F:/private/plugin-insert/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:32:22)

extract-text-webpack-plugin 提取單獨打包css文件時報錯,官方安裝部分的文檔只寫到了webpack 3,目前還沒有webpack 4版本,可以使用 extract-text-webpack-plugin@next 解決,也可以使用 mini-css-extract-plugin 。

mini-css-extract-plugin 插件用法如下:

const MiniCssExtractPlugin = require("mini-css-extract-plugin") ;const config = module.exports = {   plugins: [     new MiniCssExtractPlugin({      filename: "[name].[chunkhash:8].css",       chunkFilename: "[id].css"      })   ],   module: {    rules: [      {      test: //.css$/,      use: [         MiniCssExtractPlugin.loader,          "css-loader"       ]     }    ]    }}module.exports = config

2.babel 升級 6.x 到 7.x

(1) @babel/core

Module build failed (from ./node_modules/babel-loader/lib/index.js):Error: Cannot find module '@babel/core' babel-loader@8 requires Babel 7.x (the package '@babel/core').  If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 齐齐哈尔市| 开平市| 辽宁省| 方城县| 股票| 昔阳县| 呼玛县| 隆化县| 曲水县| 饶阳县| 青岛市| 阜阳市| 石泉县| 兰溪市| 马龙县| 南丰县| 监利县| 太白县| 万荣县| 阿鲁科尔沁旗| 灵丘县| 鄂托克前旗| 蓬安县| 武功县| 山东省| 盘锦市| 渭南市| 富民县| 海南省| 博爱县| 武威市| 马公市| 抚远县| 双峰县| 永善县| 班戈县| 武夷山市| 镇赉县| 万盛区| 左云县| 泽州县|