Skip to content

Instantly share code, notes, and snippets.

View pablohpsilva's full-sized avatar
🏠
Working from home

PHPS pablohpsilva

🏠
Working from home
View GitHub Profile
@pablohpsilva
pablohpsilva / import-specific-vs-import-deconstructor--example.js
Created November 5, 2017 20:59
import-specific-vs-import-deconstructor
// He said that importing like this:
import Comp1 from './dummy/Comp1'
// is faster than importing like this:
import { Comp1 } from './dummy'
@pablohpsilva
pablohpsilva / measure6-webpack.prod.conf.js
Created October 28, 2017 18:09
measure6-webpack.prod.conf.js
var
path = require('path'),
config = require('../config'),
cssUtils = require('./css-utils'),
glob = require('glob'),
webpack = require('webpack'),
merge = require('webpack-merge'),
baseWebpackConfig = require('./webpack.base.conf'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
@pablohpsilva
pablohpsilva / measure5-index.html
Last active October 28, 2017 17:56
measure5-index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1, maximum-scale=5, minimum-scale=1, width=device-width">
<title>Quasar App</title>
<link rel="icon" href="statics/quasar-logo.png" type="image/x-icon">
@pablohpsilva
pablohpsilva / measure5-webpack.prod.conf.js
Created October 28, 2017 17:50
measure5-webpack.prod.conf.js
var
// ...
SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'),
loadMinified = require('./load-minified'),
// ...
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
// ...
@pablohpsilva
pablohpsilva / service-worker-prod.js
Created October 28, 2017 17:47
service-worker-prod.js
(function() {
'use strict';
// Check to make sure service workers are supported in the current browser,
// and that the current page is accessed from a secure origin. Using a
// service worker from an insecure origin will trigger JS console errors.
const isLocalhost = Boolean(window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
@pablohpsilva
pablohpsilva / load-minified.js
Created October 28, 2017 17:45
load-minified.js
var fs = require('fs')
var UglifyJS = require('uglify-es')
module.exports = function(filePath) {
var code = fs.readFileSync(filePath, 'utf-8')
var result = UglifyJS.minify(code)
if (result.error) return ''
return result.code
}
@pablohpsilva
pablohpsilva / measure4-webpack.prod.conf.js
Created October 28, 2017 17:32
measure4-webpack.prod.conf.js
var
// ...
PreloadWebpackPlugin = require('preload-webpack-plugin'),
// ...
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
// ...
new PreloadWebpackPlugin({
@pablohpsilva
pablohpsilva / measure3-webpack.prod.conf.js
Created October 28, 2017 17:15
measure3-webpack.prod.conf.js
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
// ...
// Build my bundle app.js from node_modules with NO quasar code
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
async: true,
minChunks: function (module, count) {
// any required modules inside node_modules are extracted to vendor
@pablohpsilva
pablohpsilva / measure2-webpack.prod.config.js
Created October 28, 2017 16:56
measure2-webpack.prod.config.js
module.exports = merge(baseWebpackConfig, {
// ...
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: config.build.productionSourceMap,
minimize: true,
compress: {
warnings: false, // warn about potentially dangerous optimizations/code
sequences: true, // join consecutive statemets with the “comma operator”
properties: true, // optimize property access: a["foo"] → a.foo
@pablohpsilva
pablohpsilva / toolbar.js
Created October 8, 2017 19:01
InfernoJS toolbar component example using dynamicClasses
import getDynamicClasses from '#JS/dynamic-classes'
export default ({ children, fixed }) => {
return (
<div
className={getDynamicClasses({
'toolbar': true,
'toolbar-fixed': fixed
})}>
{ children }