At first, it was difficult and complicated to think of webpack, haha.Actually writing good things is really the simpler, the simpler things actually the more difficult to write.Follow the steps of how to understand the basic, how webpack use,The following is how to help the program to find the adapter step-by-step.But there are some pits that we need to crossLike what:Parser.pp.raise ,The basic problem of encountering such problems is that Babel is no
Build value is the package used by the command } ," author ":" ", "license": "ISC", "dependencies": { "webpack": "^3.0.0" }} View Code13. Run the NPM run build again14, install the configuration webpack-dev-server, realize the hot update.1. Perform NPM i webpack-dev-server--save-dev in cmd2. Modify the scripts in Package.json"Test": "Node_modules\.bin\webpack-dev-server--config./webpack/webpack.config.js--port 8089--open",View Code3, the index page JS, using absolute path, such as Htt
that has no publicpath value.2. After getting this value, use the Webpack official API compilation.assets[package to get the value].source () This is not the address, but the JS content.3. Use the template language to determine the reference JS.4. Pay special attention to whether the inject is automatically generated (5) Loader.Three ways to configure the 1.loader.1.loader in require adds the corresponding loader in the path directly to the Require file.2.CLI adds the--module-bind + correspondi
npm init -yInitialize project//-y to generate Package.json automatically, if you need to configure yourself, remove-yInstalling the various dependenciesnpm install --save vueInstalling vue2.0npm install --save-dev webpack webpack-dev-serverInstall Webpack and Webpack test server//default installation of the latest version of version 2.xnpm install --save-dev babel-core babel-loader
development environment NPM install Webpack--save-dev
Local installation to production environment NPM install Webpack--save
The specific definitions of these three environments can be queried on their own.Next need to install Babel (transcoding), React, React-dom, eslint (grammar detection), here I do not say the method of installation, directly put the configuration, we directlyInstall"Devdependencies": { "
plugins (Plugins)Plug-ins (Plugins) are used to extend the functionality of Webpack, which take effect throughout the build process and perform related tasks.Loaders and plugins are often confused, but they are really different things, so to say, loaders is used to process the source files during the package build process (jsx,scss,less. ), one process at a time, the plug-in does not directly manipulate a single file, it directly affects the entire build process.Webpack has a lot of built-in plu
Android Embedded page has a tab click actually did not respond, dizzy. But fortunately only in the hands of the Meizu phone has a problem, Huawei can, basically can be identified as compatibility issuesUse Devtools to view WebView Web page to see error messages such asIt is obvious that ES6 's generators entries function is not supported, then check the phone's Chrome kernel version is 51, check the Android chrome kernel compatibility, such as Android Chrome compatibility update so slow.Solve, o
After configuring the Appium environment in accordance with the online tutorial, the true machine runs the automated process, encountering the following error:Appium error is as follows:[ADB] Checking whether AAPT is present[adb] The android_home environment variable are not set to the ANDROID SDK root directory P Ath. Android_home is required for compatibility with SDK 23+. Checking along PATH for AAPT. [ADB] Error:could not find AAPT please set the ANDROID_HOME environment variable with the
this limit will be converted to Base64 Limit:10 24}}]},//handling react JSX syntax and ES6 syntax {// Match file test:/\.js$/,//Exclude all Files under Node_modules file Exclude:path.resolve (__dirname , ' node_modules '),//Use of loader information use:{loader: ' Babel-loader ', options:{//Presets used: Env handles ES6 syntax, react handles JSX syntax, stage-0 handles react for ES6 partial syntax unsupporte
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 /
reasons for the birth of the building
JS Modular
CSS modularity
Webpack Introduction
Methods
compiling ES6
NPM I babel-loader babel-core--save-dev
generator,set,map,array.from,array.prototype.includes
NPM Install @babel/preset-env--save-dev
Global Gasket (for application preparation)
NPM install Babel-polyfill--sa
Let command
First Look at an example
if (true) {
var a =3;
}
Console.log (a); 3
if (true) {let
b =3;
}
Console.log (b); REFERENCEERROR:B is not defined
This is the Babel compilation result
if (true) {
var a = 3;
}
Console.log (a); 3
//Babel declare the block level to a different variable name
if (true) {
var _b = 3;
}
Console.log (b); REFERENCEERROR:B is not defined
The above code is in
purifycss-webpack purify-cssIntroduction of GlobBecause we need to check the HTML template synchronously, we need to introduce node's Glob object to use. Introduce glob in the Webpack.config.js file header.constc glob = require(‘glob‘);Introduction of PURIFYCSS-WEBAPCKconstc PurifyCSSPlugin = require("purifycss-webpack");Configure PluginsnewPurifyCSSPlugin({paths:glob.sync(path.join(__dirname,‘src/*.html‘)),})BabelTurn Es6 into ES5 grammarnpm i -D babel
= {7Entry: __dirname + "/app/main.js",//Unique Portal File8 output: {9Path: __dirname + "/build",//file path to output after packagingTenFileName: "Bundle-[hash].js"//file name of the output after packaging One }, ADevtool: ' None ', - //Add the Webpack-dev-server command to the Scripts object in Package.json to turn on the local server - devserver: { theContentbase: "./public",//The directory where the page loaded by the local server is located - //when developing a
"/>
in command Prompt (Administrator), enter msiexec/package zendstudio-10.6.2-win32.win32.x86.msi enter and jump out of the installation screen. It's all about next . 650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4D/F2/wKiom1RclrCxTwydAAIkz_FUvBk585.jpg "title=" 6.jpg " Style= "Float:none;" alt= "wkiom1rclrcxtwydaaikz_fuvbk585.jpg"/>650) this.width=650; src= http://s3.51cto.com/ Wyfs02/m01/4d/f2/wkiom1rcl4hykoh5aaevlkg5np0682.jpg "title=" 8.jpg "alt=" Wkiom1rcl4hykoh5aaev
used as the path for component lazy loading.
2. asynchronous loading methods supported by webpack
Resolve => require ([URL], resolve), good support
() => System. import (URL), which has been declared on the webpack2 official website will be gradually abolished and is not recommended.
() => Import (URL), which is recommended on the official website of webpack2 and belongs to the es7 category. It must be used with the syntax-dynamic-import plug-in of b
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.