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 / 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 }
@pablohpsilva
pablohpsilva / dynamicClasses.js
Created October 8, 2017 18:58
dynamicClasses is a function that reads an object and return truthy keys as string
import { flattenObj } from '#JS/flatten'
const dynamicClasses = (obj) => {
if (obj && obj instanceof Object) {
const flatten = flattenObj(obj)
return Object.keys(flatten)
.filter(el => flatten[el])
.join(' ')
}
return ''
@pablohpsilva
pablohpsilva / flattenObj.js
Created October 8, 2017 18:57
FlattenObj will flatten an object, just like it was an array
const flattenObj = (obj) => {
if (!obj) {
return {}
}
return Object.keys(obj).reduce((acc, curr) => {
const objValue = obj[curr]
const ret = (objValue && objValue instanceof Object)
? flattenObj(objValue)
: { [curr]: objValue }
return Object.assign(acc, ret)
@pablohpsilva
pablohpsilva / toolbar.js
Last active October 8, 2017 19:03
InfernoJS + dynamic classes added WRONG
<div
className={{
'toolbar': true,
'toolbar-fixed': fixed
}}>
{ children }
</div>
@pablohpsilva
pablohpsilva / vuedynamicclass.vue
Last active October 8, 2017 19:04
Vuejs + dynamic classing example
<template>
<div
class="{
toolbar: true,
toolbar-fixed: fixed,
}">
</div>
</template>
@pablohpsilva
pablohpsilva / mdAutocomplete.vue
Created April 4, 2017 03:23
An autocomple for vue-material framework
<template lang="html">
<div class="md-autocomplete"
@focus="onFocus"
@blur="onBlur">
<md-menu md-menu-trigger
ref="menu">
<span md-menu-trigger></span>
<input class="md-input"
ref="input"
type="text"
@pablohpsilva
pablohpsilva / vmodelVSregular.vue
Created April 4, 2017 03:00
Comparing v-model with the combination of value and @input
<template>
<input v-model="someVariable" />
<!-- Is the same as: -->
<input :value="someVariable" @input="onInputUpdateSomeVariable" />
</template>
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import eslint from 'rollup-plugin-eslint';
import html from 'rollup-plugin-html';
import livereload from 'rollup-plugin-livereload';
import nodeResolve from 'rollup-plugin-node-resolve';
import path from 'path';
import serve from 'rollup-plugin-serve';
import stylus from 'rollup-plugin-stylus-css-modules';
import uglify from 'rollup-plugin-uglify';