less写法
匹配模式
1 2 3 4 5 6 7 8 9 10 11 12
| .triggle(@_,@width: 30px,@color: #ccc){ } .triggle(top,@width: 50px,@color: #ccc){ } .triggle(bottom,@width,@color){ } .sanjiao{ .triggle(top,20px,red) }
|
嵌套
1 2 3
| <ul> <li><a href=""><span></span></a></li> </ul>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| ul{ weith: 600xp; li{ list-style: none; a{ } } a{ &:hover{ coloor:red; } } }
|
@arguments
1 2 3 4
| .triggle(@width: 50px,@color: #ccc){ border: @arguments; }
|
1
| npm install --save-dev html-webpack-plugin
|
1 2 3 4 5 6 7 8 9
| const HtmlWebpackPlugin = require('html-webpack-plugin'); plugins: [ new HtmlWebpackPlugin({ title: 'Output Management', filename: 'admin.html', filename: 'html/admin.html', inject: true | 'head' | 'body' | false }) ],
|
Cleaning up the /dist folder
1
| npm install clean-webpack-plugin --save-dev
|
1 2 3 4 5
| const CleanWbpackPlugin = require('clean-webpack-plugin') plugins: [ new CleanWbpackPlugin(['dist']), ]
|
Using source maps
1 2 3 4
| module.exports = { devtool: 'inline-source-map', }
|
Using webpack-dev-server
1
| npm install --save-dev webpack-dev-server
|
1 2 3 4 5 6
| "start": "webpack-dev-server --open" devServer: { contentBase: './dist' },
|
Hot Module Replacement(HMR)
webpack.config.js
1 2 3 4 5 6 7 8 9
| const webpack = require('webpack') module.exports = { devServer:{ hot: true }, plugins: [ new webpack.HotModuleReplacementPlugin() ] }
|
CLI
1
| webpack-dev-server --hotOnly
|
编译react
1 2 3 4 5 6 7
| Module build failed: SyntaxError: react/hello.jsx: Unexpected token (5:11) 3 | export default class Hello extends React.Component { 4 | render() { > 5 | return <h1>Hello world</h1>; | ^ 6 | } 7 | }
|
1创建.babelrc文件
1
| npm install babel-preset-react babel-preset-es2015 babel-preset-stage-0 --save-dev
|
1 2 3 4 5 6 7 8
| { "presets": [ "es2015" ], "plugins": [ ["transform-react-jsx"] ] }
|
2 安装react-dom(react15)
1
| npm install react-dom --save-dev
|
1 2 3
| import ReactDOM from 'react-dom'; ReactDOM.render(<Hello />, document.getElementById('app')); React.render(<Hello />, document.getElementById('app'));//react15后不能这样写
|