在多页面项目下使用 Webpack + Vue
The article provides a guide on how to upgrade a webpack + Vue multi-page project to webpack 4 and optimize its build speed. The author explains the process of upgrading webpack, installing necessary dependencies, and optimizing the build speed by using plugins and techniques such as parallel processing and DLL packaging. The article also covers adding ES6+ support with Babel 7.
To upgrade a webpack + Vue multi-page project to webpack 4 and optimize its build speed, follow these steps:
Webpack 4 Upgrade:
webpack-cliwebpack 4.xmini-css-extract-plugin (replaces extract-text-webpack-plugin)css-loader, file-loader, url-loader, vue-style-loader, and vue-template-compilermode optionextract-text-webpack-plugin configuration with the mini-css-extract-plugin configurationoptimization option to configure file splittingvue-loader to version 15 and use a webpack plugin for proper usagehtml-webpack-plugin to the next version for resource file injectionoptimize-css-assets-webpack-plugin and terser-webpack-pluginBuild Speed Optimization:
speed-measure-webpack-plugin to analyze build timeTerserPlugin and use thread-loader or HappyPack for multi-threaded transformation of loadersDllPlugin and update the webpack configuration to use webpack.DllReferencePlugin and manually reference the generated DLL files in HTMLES6+ Support:
@babel/core, @babel/plugin-proposal-class-properties, @babel/plugin-proposal-decorators, @babel/plugin-syntax-dynamic-import, @babel/plugin-transform-runtime, @babel/preset-env, @babel/runtime, babel-loader, and @babel/polyfill@babel and specifying options for @babel/plugin-transform-runtimeThe article provides detailed steps on how to upgrade a webpack + Vue multi-page project to webpack 4 and optimize its build speed. It covers the installation of necessary dependencies, modification of webpack configurations, and usage of plugins to improve build performance. Additionally, the article explains how to add ES6+ support using Babel 7. The provided guide is a valuable resource for developers working on multi-page projects with webpack and Vue.