Skip to content

Instantly share code, notes, and snippets.

@ybonnel
Forked from anonymous/elemjsx.es6
Created August 11, 2015 12:03
Show Gist options
  • Save ybonnel/3900e13144d90725baa6 to your computer and use it in GitHub Desktop.
Save ybonnel/3900e13144d90725baa6 to your computer and use it in GitHub Desktop.
Use jsx with Elem.js
const Elem = require('elemjs');
Elem.jsx = (type, attributes, ...children) => {
if (attributes === null) {
return Elem.sel(type, children);
}
return Elem.el(type, attributes, children);
};
export default Elem;
const Elem = require('elemjsx');
Elem.render(
<h1>Hello jsx</h1>,
document.body
);
var webpack = require('webpack');
module.exports = {
resolve: {
root: './src',
extensions: ['', '.es6']
},
entry: {
app: ['./src/main.es6']
},
output: {
path: 'public/',
filename: 'bundle.js',
library: 'MyLib',
libraryTarget: 'umd'
},
devServer: {
contentBase: "./public"
},
module: {
loaders: [
{
test: /\.js|\.es6$/,
exclude: /node_modules/,
/* IMPORTANT : jsxPragma=Elem.jsx */
loader: 'babel-loader?stage=0&optional=runtime&jsxPragma=Elem.jsx'
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment