Webpack.config.js Configuration

Source: Internet
Author: User
Tags script tag

Const Htmlwebpackplugin = require (' Html-webpack-plugin ');module.exports = {//Portal File Configuration//Value: Object/String//Entry: './src/main.js ',entry: {//key: The name of the file when it is output//value: For file pathmain: './src/main.js '    },//Output file configurationoutput: {path: __dirname+ '/dist ',//[hash:20] random number. Ensure that the name is different and prevent the server from caching//filename: ' [name]. [Hash:20].js 'filename: ' [name].js '    },//dynamic load script tag //Processing Templatescnpm Install html-webpack-plugin-dplugins: [New Htmlwebpackplugin ({//Role of the fileTemplate: './index.html ',//Output filefilename: ' index.html '        })    ],module: {//configuration file compilation rulesrules: [//compile ES6 syntaxusing Babel-loadercnpm Install Babel-loader babel-core-dcan only parse the basic syntax, methods, functions cannot be implemented            {test:/\.js$/,//matching rules for file paths that need to be compiledexclude:/node_modules/,//removal of file pathloader: ' Babel-loader ',configuration of the//babel-loader                /*options: {//Presetsthe functions and methods of ES6 cannot be compiled:(the es6 used at compile time will provide method conversions for development projects, frameworks)cnpm Install babel-plugin-transform-runtime-dcnpm Install babel-runtime-sThe code used to insert the ES5 methodpresets: [//' env '//If a single configuration is preset, configure an array//The first value is a preset name//second value for this preset configuration[' env ', {Target: {browsers: [' >1% ', ' last 2 versions ']                            }                        }]//react, use the following, and use the other one.[' env ', ' react ']                    ],plugins: ["Transform-runtime"                    ]                }                */            },parse vue into JSInstalling Vuecnpm Install vue vue-router vuex-scnpm Install vue-loader-d (after installation note Check that the dependent module is installed)            {test:/\.vue$/,loader: ' Vue-loader '            },//Compile CSScnpm Install Css-loader style-loader-d            {test:/\.css$/,loader: ' Style-loader!css-loader '            }, //Compiling other files (PNG gif jpeg jpg TTF)Url-loadercnpm Install url-loader-d            {test:/\. (png|jpeg|jpg|ttf|gif)/,loader: ' Url-loader '            }         ]    }}

Webpack.config.js Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.