Skip to content

Instantly share code, notes, and snippets.

View lukewatts's full-sized avatar

Luke Watts lukewatts

View GitHub Profile
@lukewatts
lukewatts / index.js
Created October 16, 2018 18:36
Medium Article - Use JSX with any MV* framework - Code Snippets - 11 - Testing jsx-render
import dom from 'jsx-render';
class Test {
constructor()
{
var app = document.getElementById('app')
var htmlCreatedByJSXRender = dom('h1', {}, 'Test Class');
app.appendChild(htmlCreatedByJSXRender);
}
}
@lukewatts
lukewatts / index.html
Last active October 16, 2018 18:07
Code Revisions 1 Medium Article - Use JSX with any MV* framework - Code Snippets - 10 - HTML File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app"></div>
@lukewatts
lukewatts / package.json
Last active October 16, 2018 17:48
Code Revisions 1 Medium Article - Use JSX with any MV* framework - Code Snippets - 09 - Add webpack to scripts
{
"scripts": {
"start": "webpack --watch"
},
"dependencies": { },
"devDependencies": { }
}
@lukewatts
lukewatts / index.js
Created October 16, 2018 07:57
Medium Article - Use JSX with any MV* framework - Code Snippets - 08 - Test Webpack
class Test
{
constructor()
{
console.log('Test class successfully initialized');
}
}
new Test;
@lukewatts
lukewatts / directory-structure-01.txt
Created October 16, 2018 07:54
Medium Article - Use JSX with any MV* framework - Code Snippets - 07 - Webpack Configuration directory structure
root
|-- node_modules
|-- ...
|-- src
|-- index.js
|-- .babelrc
|-- index.html
|-- package.json
|-- webpack.config.js
@lukewatts
lukewatts / webpack.config.js
Last active October 16, 2018 07:48
Medium Article - Use JSX with any MV* framework - Code Snippets - 06 - Initial Webpack Configuration
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, 'src', 'index.js'), // Main file will be at ./src/index.js
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js' // Bundled file will be at ./build/bundle.js
},
module: {
rules: [
@lukewatts
lukewatts / .babelrc
Last active October 16, 2018 07:24
Medium Article - Use JSX with any MV* framework - Code Snippets - 05 - Babel Config for jsx-render
{
"plugins": [
["@babel/plugin-transform-react-jsx", {
"pragma": "dom"
}]
]
}
@lukewatts
lukewatts / index.js
Created October 15, 2018 15:46
Reactbone.js index
import Reactbone, { Component } from './Reactbone';
class Test extends Component
{
constructor()
{
super();
this.view('#app');
}
@lukewatts
lukewatts / Reactbone.js
Created October 15, 2018 15:45
Reactbone.js
import dom from 'jsx-render';
const Reactbone = (tagname, attrs, ...children) => dom(tagname, attrs, ...children);
export default Reactbone;
export class Component {
view(el)
{
const $el = document.querySelector(el);
$el.appendChild(this.render());
@lukewatts
lukewatts / install-npm-packages.sh
Last active October 15, 2018 15:40
Medium Article - Use JSX with any MV* framework - Code Snippets - 04
yarn add backbone underscore webpack webpack-cli babel-loader @babel/core @babel/plugin-transform-react-jsx jsx-render