Skip to content

Instantly share code, notes, and snippets.

View prateekbh's full-sized avatar
🌏
Lets talk web?

Prateek Bhatnagar prateekbh

🌏
Lets talk web?
View GitHub Profile
var webpack = require('webpack');
module.exports = {
entry: './index',
output: {
path: __dirname + '/public',
publicPath: '/public/',
filename: 'bundle.js'
},
module: {
import riot from 'riot';
import tag from './tags/header.tag';
//function to load routes from primary chunk
function loadPrimaryChunk(){
return new Promise((resolve,reject)=>{
//this line ensures cart and co tags are bundled into one file
require.ensure(['./tags/home.tag'], (require) => {
require('./tags/home.tag');
resolve();
<app-route>
<router show-routes={true} on-routechange={fireRouteChange} on-tagnotfound={fireTagnotfound}>
<route path='/' component='home'></route>
<route path='user'>
<route path='/profile/:user' component='user-component'></route>
</route>
<route path='messages'>
<route path='/outbox' component='msg-outbox'></route>
<route path='/:from-:to' component='{prplFunc}'></route>
</route>
var CommonsPlugin = new require("webpack/lib/optimize/CommonsChunkPlugin");
var webpack = new require("webpack");
module.exports = {
entry: {
home: "./scripts/home.js",
apis: "./scripts/api.js",
app: "./scripts/app.js",
vendor: "./scripts/vendor.js"
},
<rtr-router>
<router>
<route path ='/' component="rtr-home"/>
<route path ='/apis' component={this.parent.loadApiPage}/>
<route path ='/isomorphism' component="rtr-isomorphism"/>
<route path ='/prpl' component={this.parent.loadPrplPage}/>
</router>
<script>
this.loadApiPage = function(){
return new Promise((resolve,reject)=>{
var riot = require("riot");
require("./tags/*.tag");
console.log(riot.render('app-router'),{location:req.url});
/*
* location: param passed to router to select which route to render
*/
{
"name": "riotcodesplit",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
var webpack = require('webpack');
module.exports = {
entry: './index',
output: {
path: __dirname + '/public',
publicPath: '/public/',
filename: 'bundle.js'
},
module: {
var webpack = require('webpack');
var path = require("path");
var CommonsPlugin = new require("webpack/lib/optimize/CommonsChunkPlugin");
var VendorChunkPlugin = require('webpack-vendor-chunk-plugin');
module.exports = {
entry: {
home: './home.js',
browse: './browse.js',
product: './product.js',
var webpack = require('webpack');
var path = require("path");
var CommonsPlugin = new require("webpack/lib/optimize/CommonsChunkPlugin");
var VendorChunkPlugin = require('webpack-vendor-chunk-plugin');
module.exports = {
entry: {
app:'./app.js',
vendor: './vendor.js'
},