Created
May 15, 2017 13:40
-
-
Save Tom-Millard/de120f6096de88a04ee1a8aa936c4dbc to your computer and use it in GitHub Desktop.
broken
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
import('./components/List').then((List) => { | |
render(<List />, document.getElementById('main')); | |
}); |
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
{ | |
"presets" : ["es2015"], | |
"plugins": [ | |
["transform-react-jsx", { "pragma":"h" }, "syntax-dynamic-import"] | |
] | |
} |
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
import { h, render, Component } from 'preact'; | |
import './scss/main.scss'; | |
export class List extends Component { | |
constructor(props){ | |
super(props); | |
this.state = { data : [] }; | |
this.loc = window.location.pathname; | |
console.log("loaded"); | |
} | |
componentWillMount() { | |
document.getElementById('main').innerHTML += "<section id='list' class='section-panel'></section>"; | |
fetch("/json" + this.loc, {headers : new Headers({'Content-Type' : 'application/json'})}) | |
.then((data) => { | |
return data.json(); | |
}).then((j) => { | |
this.setState(j); | |
}); | |
} | |
actionHandlerGetMovie(film, event){ | |
event.preventDefault(); | |
} | |
render() { | |
if(this.state.data.length == 0){ | |
return; | |
} | |
let f = this.state.data.map((film) => { | |
return <li>{film.name} <a href={"/movie/" + film.id + "/" + encodeURI(film.name)} onClick={this.actionHandlerGetMovie.bind(this, film)}>click me {film.id}</a></li> | |
}); | |
return <ul className='list'>{f}</ul> | |
} | |
} | |
render(<List />, document.getElementById('list')); |
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 webpack = require('webpack'); | |
const path = require('path'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const BUILD_DIR = path.resolve(__dirname, 'public/js'); | |
const APP_DIR = path.resolve(__dirname, 'resources/assets/js'); | |
const extractCore = new ExtractTextPlugin("./public/css/core.css"); | |
const extractApp = new ExtractTextPlugin("./public/css/app.css"); | |
const config = { | |
entry: APP_DIR + '/app.js', | |
output: { | |
path: BUILD_DIR, | |
filename: 'app.js', | |
publicPath: '/js/', | |
chunkFilename: '[name].js' | |
}, | |
module : { | |
loaders : [ | |
{ | |
test : /\.jsx?/, | |
include : APP_DIR, | |
loader : 'babel-loader', | |
options: { | |
presets: [['es2015', {modules: false}]], | |
plugins: ['syntax-dynamic-import'] | |
} | |
}, | |
{ | |
test: /\.scss$/, | |
use: [ | |
{ | |
loader: "style-loader" | |
}, | |
{ | |
loader: "css-loader", | |
options: { | |
minimize: true | |
} | |
}, | |
{ | |
loader: "sass-loader", | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
extractCore, | |
extractApp | |
] | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment