This file contains 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
import React from "react"; | |
import { Component1, Component2, Component3 } from "./file"; | |
const Switch = ({ n, …rest }) => { | |
switch(n) { | |
case 1: | |
return <Component1 {...rest}/>; | |
case 2: | |
return <Component2 {...rest}/>; | |
case 3: |
This file contains 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
import React from "react"; | |
import { Component1, Component2 } from "./file"; | |
const Switch = ({ condition, …rest }) => ( | |
<div> | |
{condition ? <Component1 {…rest}/> : <Component2 {…rest}/>} | |
</div> | |
) |
This file contains 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
var oneWeek = 86400000*7; | |
app.use(express.static(path.join(__dirname, "public"), { maxAge: oneWeek, lastModified: true })); |
This file contains 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
//this middleware serves all js files as gzip | |
app.use(function(req, res, next) { | |
var originalPath = req.path; | |
if(!originalPath.endsWith(".js")) { | |
next(); | |
return; | |
} | |
try { | |
var stats = fs.statSync(path.join("public", `${req.path}.gz`)); | |
res.append('Content-Encoding', 'gzip'); |
This file contains 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
plugins: [ | |
new CompressionPlugin({ | |
asset: "[path].gz[query]", | |
algorithm: "gzip", | |
test: /\.js$|\.css$|\.html$/, | |
threshold: 10240, | |
minRatio: 0.8 | |
}) | |
] |
This file contains 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
var compression = require('compression'); | |
var app = express(); | |
app.use(compression()); |
This file contains 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 determineDate = () => { | |
import('moment').then((moment) => { | |
console.log(moment().format()); | |
}).catch((err) => { | |
console.log('Failed to load moment', err); | |
}); | |
} | |
determineDate(); |
This file contains 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: [ | |
["es2015", { loose: true, modules: false }], | |
"react" | |
] | |
... |
This file contains 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: [ | |
["es2015", { loose: true }], | |
"react" | |
] | |
... |
This file contains 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
plugins: [ | |
new webpack.optimize.UglifyJsPlugin({ | |
output: { | |
comments: false | |
}, | |
mangle: true, | |
sourcemap: false, | |
debug: false, | |
minimize: true, | |
compress: { |