-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set up proxy for web pack bundle. Development and Production can be d…
…one without hassle.
- Loading branch information
Showing
8 changed files
with
150 additions
and
29 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ build/Release | |
node_modules | ||
|
||
# Webpack autogenerate files | ||
public/bundle.js | ||
public/build |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import webpack from 'webpack'; | ||
import WebpackDevServer from 'webpack-dev-server'; | ||
import webpackConfig from './../webpack.config.js'; | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
|
||
export default function() { | ||
|
||
// First we fire up Webpack an pass in the configuration we | ||
// created | ||
let bundleStart = null; | ||
let compiler = webpack(webpackConfig); | ||
|
||
// We give notice in the terminal when it starts bundling and | ||
// set the time it started | ||
compiler.plugin('compile', () => { | ||
console.log('Bundling...'); | ||
bundleStart = Date.now(); | ||
}); | ||
|
||
// We also give notice when it is done compiling, including the | ||
// time it took. Nice to have | ||
compiler.plugin('done', () => { | ||
console.log('Bundled in ' + (Date.now() - bundleStart) + 'ms!'); | ||
}); | ||
|
||
var bundler = new WebpackDevServer(compiler, { | ||
|
||
// We need to tell Webpack to serve our bundled application | ||
// from the build path. When proxying: | ||
// http://localhost:3000/build -> http://localhost:8080/build | ||
publicPath: '/build/', | ||
|
||
// Configure hot replacement | ||
hot: true, | ||
|
||
// The rest is terminal configurations | ||
quiet: false, | ||
noInfo: true, | ||
stats: { | ||
colors: true | ||
} | ||
}); | ||
|
||
// We fire up the development server and give notice in the terminal | ||
// that we are starting the initial bundle | ||
bundler.listen(8090, 'localhost', () => { | ||
console.log('Bundling project, please wait...'); | ||
}); | ||
|
||
}; |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
var buildPath = path.resolve(__dirname, 'public', 'build'); | ||
var mainPath = path.resolve(__dirname, 'frontend', 'index.jsx'); | ||
|
||
module.exports = { | ||
devtool: 'source-map', | ||
entry: mainPath, | ||
output: { | ||
path: buildPath, | ||
filename: 'bundle.js' | ||
}, | ||
module: { | ||
loaders: [{ | ||
test: /\.css$/, | ||
loader: 'style!css' | ||
}, { | ||
// tell webpack to use jsx-loader for all *.jsx files | ||
test: /\.jsx$/, | ||
loaders: ['jsx-loader?insertPragma=React.DOM&harmony', 'babel?stage=1'] | ||
}, { | ||
test: /\.js$/, | ||
loaders: ['babel?stage=1'] | ||
}] | ||
}, | ||
externals: { | ||
// don't bundle the 'react' npm package with our bundle.js | ||
// but get it from a global 'React' variable | ||
'react': 'React' | ||
}, | ||
resolve: { | ||
// you can now require('file') instead of require('file.coffee') | ||
extensions: ['', '.js', '.jsx'] | ||
} | ||
}; |