Today is generally popular scaffolding use, so the general React\vue\angular official website has recommended installation method,There are several types of react, typically react-cli or self-configuring.Package.json{ "Name": "Test", "Version": "1.0.0", "description": "Test", "Main": "Index.js", "Scripts": { "Test": "Echo \" Error:no test specified\ " exit 1", "Start": "Webpack-dev-server" }, "Author": "Zhangzhicheng", "License": "ISC", "Dependencies": { "React": "^16.2.0",
) preprocessing function. Users now have more flexibility to introduce fine-grained logic, such as compression, packaging, language translation, and more test: regular expressions, to match file names (must) Loader: The list of loaders to load, use! Load more than one (must) Include/exclude: Manually add files (folders) that must be processed (folder) or block files (folders) that you do not need to process (optional); query: Provide additional setup options for loaders (optional) use Loader
In
--mode development # 视具体需求
npm publish --registry http://ubuntu-17:4873 # --force
In the Mydemo project we add references
yarn add myHammer --registry http://ubuntu-17:4873
Modify the index.js following:
const myGreeting = require('myGreeting');
const {base64} = require('myHammer');
(function () {
let greeting = myGreeting('Rattz');
console.log(base64.encode(greeting));
})();
Run up
$ node index.js
SGVsbG8gUmF0dHo=About Tree Shaking
Mention a little bit about the tree Shaking,
private NPM warehouse
webpack --mode development # 视具体需求npm publish --registry http://ubuntu-17:4873 # --force
In the Mydemo project we add references
yarn add myHammer --registry http://ubuntu-17:4873
Modify the index.js following:
const myGreeting = require('myGreeting');const {base64} = require('myHammer');(function () { let greeting = myGreeting('Rattz'); console.log(base64.encode(greeting));})();
Run up
$ node index.jsSGVsbG8gUmF0dHo=About Tree Shaking
Mention a little bit about th
Tags: no latest BFS group pts syslog ISO inotify proc1.locateThe locate command is a file search command that searches faster than the find command because it does not search for a specific directory.Instead, it searches for a database that contains all the local file information. The Linux system automatically creates this database,and automatically updated every day, so use locate this command to find the latest changed files. To avoid this situationYou can manually update the database by usin
", this.props.name);}You will find it cumbersome and not intuitive to use HTML. So react provides the JSX (JavaScript eXtension) syntax that allows you to write HTML code in JS.render () { return div>Hello {this.props.name}div>;}What is JSXJSX provides an XML-like extension based on the ECMAScript. JSX and HTML are a bit like, but there are different places. For example, the class attribute in HTML is classname in JSX. Other different places, you can refer to the FB HTML Tags vs. Reac
. This ES6 syntax, for example, can be aided by Babel-loader:Installing Babel-loaderNPM Install--save-dev Babel-loaderConfigure Webpack.config.jsTo add a module to the Module.exports value:Module.exports = {Entry: {App: [' Webpack/hot/dev-server ', './main.js ']},Output: {FileName: ' Bundle.js '},Module: {Loaders: [{test:/\.js$/, Loader: '
Copyright belongs to the author.Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.Zhang XuanLinks: http://zhuanlan.zhihu.com/p/20367175Source: KnowIf you do not have the ES6 grammar support now, it is a little bit of force, in fact, we all know this is also very simple, because we have a great BabelStart with a variety of loadernpm install babel-loader
from 'vue '; import hello from '. /hello. vue '; new Vue ({el: "# app", template:'
In this case, the project cannot run because. the webpack of the vue file cannot be anything else. It must be handled by the corresponding vue-loader, and you will find hello. ES6 syntax is used in vue. In this case, the corresponding syntax conversion loader is used to convert ES6 into ES5 syntax compatible with mainstream browsers. here we need to use the babel tool
React + Webpack construction and packaging optimization, reactwebpack
This article describes how to optimize React + Webpack construction and packaging. The details are as follows:
Use babel-react-optimize to optimize the React code
Check unused libraries and remove import references
Package the class libraries as needed, such as lodash and echart.
Lodash can be optimized using babel-plugin-lodash.
Note tha
provides a powerful way to process the frontend build steps. Loader can convert files from different languages (such as TypeScript) to JavaScript, or convert Inline images to data URLs. Loader even allows you to directly import CSS files in the JavaScript module!
From this, we can see that the powerful function of loader is analyzed as follows:
The role of conversion. All files used for development are converted into html, css, js, img, and other required formats for webpage loading.
The c
), and the third section is the supplementary C function. These segments are separated by %. So let's take a look at the previous Lex code.
% Using Babel; % Using Babel. parser; % namespace Babel. lexer % [0-9] + {return (INT) tokens. number;} [A-Z] + {return (INT) tokens. lowletter;} [A-Z] + {return (INT) tokens. capletter ;}.; % /*.... */
The code is divide
Can compile es2015 with Babel, can hot compile, can load static resources (Js/css/font/image). is a very general development environment, although not intelligent. But very well extendedNPM Installation list:NPM Install Babel-CLI Babel-core Babel-loader Babel-preset-
Initializing the Environment npm init -y Initialize ProjectInstalling the various dependenciesnpm install --save vueInstalling vue2.0npm install --save-dev [emailprotected]^2.1.0-beta.25 [emailprotected]^2.1.0-beta.9Install Webpack and Webpack test Server, the default installation is version 1.0, so you must specify a version numbernpm install --save-dev babel-core babel-loader
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.