Skip to content

Instantly share code, notes, and snippets.

View matheus1lva's full-sized avatar
😃
set yourself free

Matheus matheus1lva

😃
set yourself free
View GitHub Profile
module.exports = {
...
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.MY_ENV_VARIABLE)
}),
]
}
@matheus1lva
matheus1lva / index.js
Created January 22, 2019 12:04
code splitting/dynamic import
// generates a single file for your component.js
// only when used.
// This returns a promise, which needs to be resolved.
import('./components/component.js')
// creates a chunk for each file inside your components folder
// This is called require context (which require.context is used under the hood)
// Webpack is smart enough to do that for you!
const myComponents = (componentName) => import(`./components/${componentName}.js`)
@matheus1lva
matheus1lva / webpack.config.js
Created January 22, 2019 11:52
webpack future Emit strategy
module.exports = {
// ...
output: {
futureEmitAssets: true
}
}
eval("/*\n Copyright © 2018 Andrew Powell\n\n This Source Code Form is subject to the terms of the Mozilla Public\n License, v. 2.0. If a copy of the MPL was not distributed with this\n file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n The above copyright notice and this permission notice shall be\n included in all copies or subsantial portions of this Source Code Form.\n*/\nconst { error, refresh, warn } = __webpack_require__(/*! ./log */ \"./node_modules/webpack-plugin-serve/lib/client/log.js\");\n\n// ignore 1008 (HTTP 400 equivalent) and 1011 (HTTP 500 equivalent)\nconst ignoreCodes = [1008, 1011];\nconst maxAttempts = 10;\n\nclass ClientSocket {\n constructor(options, ...args) {\n this.args = args;\n this.attempts = 0;\n this.eventHandlers = [];\n this.options = options;\n this.retrying = false;\n\n this.connect();\n }\n\n addEventListener(...args) {\n this.eventHandlers.push(args);\n this.socket.addEventListener(...args);\n }\n\n connect() {\n if (this.so
```
{ source: '',
chunk:
Chunk {
id: 'main',
ids: [ 'main' ],
debugId: 1000,
name: 'main',
preventIntegration: false,
entryModule:
import * as React from 'react';
import Loading from './components/Loading';
import { RouteComponentProps } from 'react-router';
interface AsyncRouteProps {
loading: Promise<any>;
routeProps: RouteComponentProps<any> & { [key: string]: any };
}
interface AsyncRouteState {
register override
register override
/home/matheus/forks/GrCartuchos/frontend/node_modules/tapable/lib/HookCodeFactory.js:73
instance._x = options.taps.map(t => t.fn);
^
TypeError: Cannot read property 'fn' of undefined
at instance._x.options.taps.map.t (/home/matheus/forks/GrCartuchos/frontend/node_modules/tapable/lib/HookCodeFactory.js:73:41)
at Array.map (<anonymous>)
at SyncHookCodeFactory.setup (/home/matheus/forks/GrCartuchos/frontend/node_modules/tapable/lib/HookCodeFactory.js:73:30)
@matheus1lva
matheus1lva / some gist
Created November 1, 2018 19:01
tapable debug
register { type: 'sync',
fn: [Function],
name: 'HotModuleReplacementPlugin' }
register { type: 'sync',
fn: [Function],
name: 'HotModuleReplacementPlugin' }
call [ Chunk {
id: 0,
ids: [ 0 ],
debugId: 1000,
import React from 'react';
import PropTypes from 'prop-types';
import Loading from './components/Loading';
class AsyncRoute extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
loaded: false
};
@matheus1lva
matheus1lva / gist:3512230f728cb7266487cfb33e1d49f6
Created April 25, 2018 23:09
english stuff that must use
MUST USE:
- IT WOULD BE SENSIBLE/ADVISABLE TO...
- THE ODDS ARE (THAT)... (PARA COISAS FORA DO NORMAL)
- WHO SHOULD I (VERB) BUT (SOMETHING ELSE)
- IF I WERE IN YOUR SHOES ...
- I HOPE YOU'LL TAKE THIS IN THE SPIRIT IN WHICH IT IS INTENDED
- SWEARS BY