1. Add packaging command Add configuration to Order:
"build:dev": "vue-cli-service build --mode dev", "build:prod": "vue-cli-service build --mode prod" 2. Run the packaged code Do not double-click
Solution: User -> Personal User -> Delete Start the packaged directory : 3. Package and specify different environment variablesAdd environment variables:
Use // .env.dev ##Development environment NODE_ENV=development ##Variables start with VUE_APP_ VUE_APP_URL=http://www.dev.com // .env.prod ##Production environment NODE_ENV=production VUE_APP_URL=http://www.prod.com 4. Package custom files
4.1 Remove third-party packages Code breakdown:
Remove third-party packages: Use
module.exports = { // Open the relative path of the file access Independent project access through the project root directory publicPath: './', // When developing, you don't need map online --> provide code mapping to facilitate debugging code productionSourceMap: process.env.NODE_ENV == 'development' ? true: false, // Configure webpack configureWebpack: config => { // config---vuecli default configurationObject.assign(config, { // Exclude dependent packages externals: { vue: 'Vue' } }) }, } 4.2 gzip compression
5. Packaging error:
Packaging will generate files ending in gz: let CompressionWebpackPlugin = require('compression-webpack-plugin') configureWebpack: config => { let plugins = [ new CompressionWebpackPlugin({ // Compression algorithm: 'gzip', // Match compressed file test: /\.js$|\.css$/, // For compression threshold greater than 10k: 10240 }) ] if (process.env.NODE_ENV == 'production') { config.mode = "production" config.plugins = [...config.plugins, ...plugins] } else { config.mode = 'development' } }, Browser view:
Packaging deployment mode:
History: After packaging, the scaffolding refresh will not 404, but the online will 404 This is the end of this article about the detailed process of Vue front-end packaging. For more relevant Vue front-end packaging detailed process content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Example code for implementing div concave corner style with css
>>: Analysis and solutions to problems encountered in the use of label tags
Unlike other types of design, web design has been ...
The complete syntax of the SELECT statement is: (...
Table of contents Passing parameters between pare...
In the trend of gradual transition from tradition...
One environment Alibaba Cloud Server: CentOS 7.4 ...
For Windows User Using openGauss in Docker Pull t...
Table of contents Requirement: Query ongoing acti...
Table of contents Port-related concepts: Relation...
“How to make a website look high-end? Or more des...
1. Overview In the daily operation and maintenanc...
Dimensionality reduction of two-dimensional array...
HTML tags have special tags to handle the title of...
Its function is to set a global style. Then your s...
method: Take less in the actual project as an exa...
Use auto.js to automate daily check-in Due to the...