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
"/>
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
code before it can run.
Use JSX in Vue
The Vue framework does not specifically support JSX. In fact, it does not need to be supported because JSX will eventually compile as a standard JavaScript code. In this case, why can Vue and JSX be used together? It's easy, because Vue supports Virtual DOM, you can use JSX or other preprocessing languages, as long as the render method works properly.
Vue officially provides a plug-in called babel-plugin-transfo
Webpack Common plug-in installation commands:1:npm Install Html-webpack-plugin--save-dev//automatically quickly help us to generate HTML. 2:npm Install Css-loader style-loader--save-dev//style file, we need two kinds of loader,css-loader and Style-loader,css-loader will traverse CSS file , find all the URLs (...) and processing. Style-loader will insert all the styles into a style tag on your page. 3:npm Install Babel-loader css-loader style-loader--s
Webpack Common plug-in installation commands:1:NPM Install Html-webpack-plugin--save-dev//automatically quickly help us to generate HTML.2:NPM Install Css-loader style-loader--save-dev//style file, we need two kinds of loader,css-loader and Style-loader,css-loader will traverse the CSS file, Find all the URLs (...) and processing. Style-loader will insert all the styles into a style tag on your page.3:NPM Install Babel-loader css-loader style-loader--
--hot " }, " keywords ": [], " author ":", "license": "ISC"}// index.htmlsrc= "http://localhost:8080/ Bundle.js ">//Note src Properties v. New Webpack.config.js fileCreate a new Webpack.config.js file under the project directory with the following contents:Module.exports = { entry: + "/app/main.js",// The only entry file output that has been mentioned several times : { + "/build",// The place where the files are packed after filename : "bundle.js"// file name of the output file a
Create-react-app is a 0 configuration command-line tool from Facebook that helps you automatically create WEBPACK+ES6-based react project templates1: First create a new project in Webstorm2: If it is not the latest version of NPM, install the latest version of NPMNPM Install NPM @latest3: Related configurations commonly used in Setup projectsYarn Add React-redux redux redux-thunk react-router-dom thunk [email protected] Babel-plugin-transform-decorato
"
Inline
Set to true , automatically refresh the page when the source file changes
Historyapifallback
Very useful when developing a single page application, it relies on the HTML5 history API, and if set to true , all jumps will point to index.html
Module.exports = { ' eval-source-map ', entry: + '/app/main.js ', output: { + "/public", "Bundle.js" }, devserver: { "./public",// The directory where the local server loads the page
Objective:After grunt, gulp to achieve automation, Webpack also lead the front-end packaging trends, it is well known that VUE-CLI scaffolding is based on the Webpack project packaging. While Webpack is still rising momentum, another package artifact turned out--parcel.Parcel Fast, 0 configured WEB application featuresQuick Pack Parcel uses worker processes to enable multi-core compilation and has a file system cache that can be rebuilt quickly even after a reboot.Package All ResourcesParcel
ObjectiveBuilding the development environment of the former, can be developed. However, in the actual project, different environments have different construction needs. Here, the configuration of the development environment and production environment is extracted separately, and some simple optimizations are made.
Separate public configurations for different environments
Although different environments have different construction needs, but still have the same part, here will be pa
the MAC environment, win under the basic difference is not too much
1. Create a new state directory under the specified directory (command line operation)
mkdir State
2. Initialize the project with yarn (command line operation)
CD State
yarn Init
In the above steps all the way to enter
3. Install some dependencies (command line operation)
Yarn Add react react-dom webpack webpack-dev-server babel-core babel
Adding \ Config\polyfills.js to the project Adding \config\webpack.config.dev.js to the project Adding \config\webpack.config.pro D.js to the project Adding \config\webpackdevserver.config.js to the project Adding \config\jest\csstransform.js to the Project Adding \config\jest\filetransform.js to the project Adding \scripts\build.js to the project Adding \scripts\sta Rt.js to the project Adding \scripts\test.js to the projectupdating the dependencies removing react-scripts from Depende Ncies A
below loop would output:
"Dwayne"
"Charrington"
27
"Aquarius"
For (var p in person) {
if (Person.hasownproperty (p)) {
Console.log (Person[p]);
}
}
You may have noticed that I use a method called hasOwnProperty. This method checks whether the object has a specified property directly on its prototype, not an inherited value. If you are in for.. In loops do not use hasOwnProperty, most JavaScript linter will throw an error.For: of cyclesThis is a new
module in strictly controlled context. The loader supports load (url, moduleInstance, error), createModule (object, globalModuleReferences), and so on.CommonJS module for serversFor server-oriented developers, the module system proposed in ES. next is not limited to browser-side modules. For example, the following is a server-side CommonJS module:File. js// Io/File. jsExport function open (path ){//...};Export function close (hnd ){//...};LexicalHandler. js// Compiler/LexicalHandler. jsModule f
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.