This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Building a router</title> | |
<script> | |
// Put John's template engine code here... | |
(function () { | |
// A hash to store our routes: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Use Proxy to implement observable | |
*/ | |
function observable (obj, onchange) { | |
return new Proxy(obj, { | |
set (target, key, value) { | |
Reflect.set(target, key, value) | |
onchange(key, value) | |
}, | |
delete (target, key) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add (a, b) { | |
return a + b | |
} | |
foo = [10, 20, 30, 40] | |
bar = foo.map(add.bind(null, 5)) | |
console.log(bar) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*, *:before, *:after { | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
box-sizing: border-box; | |
} | |
*, *:before, *:after { | |
box-sizing: inherit; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
module: { | |
rules: [{ | |
test: path.resolve(__dirname, '../pdmp/scripts/lib/jquery-1.12.4.js'), | |
use: [{ | |
loader: 'expose-loader', | |
options: '$' | |
}, | |
{ | |
loader: 'expose-loader', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/michael-ciniawsky/postcss-load-config | |
// | |
const webpackConfig = require('./build/webpack.base.conf.js') | |
// 使用 postcss-import-webpack-resolver 就可以识别别名了。 | |
const createResolver = require('postcss-import-webpack-resolver') | |
module.exports = { | |
"plugins": { | |
// to edit target browsers: use "browserslist" field in package.json | |
// https://www.npmjs.com/package/postcss-import-webpack-resolver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"presets": [ | |
["env", { "modules": false }], | |
"stage-2" | |
], | |
"plugins": ["transform-runtime", "transform-vue-jsx"], | |
"comments": false, | |
"env": { | |
"test": { | |
"presets": ["env", "stage-2"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
That syntax is an experimental proposed syntax for the future, it is not part of es2015 or react so you'll need to enable it. | |
npm install --save-dev babel-plugin-transform-object-rest-spread | |
and add | |
"plugins": ["transform-object-rest-spread"] | |
alongside your existing presets. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const webpack = require('webpack') | |
const htmlWebpackPlugin = require('html-webpack-plugin') | |
module.exports = { | |
entry: { | |
app: './src/main.js', | |
moduleA: './src/moduleA.js', | |
moduleB: './src/moduleB.js', | |
moduleC: './src/moduleC.js' | |
}, |