-
-
Save ybonnel/3900e13144d90725baa6 to your computer and use it in GitHub Desktop.
Use jsx with Elem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Elem = require('elemjsx'); | |
Elem.render( | |
<h1>Hello jsx</h1>, | |
document.body | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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