Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active August 29, 2015 14:09
Show Gist options
  • Save ryanflorence/cde19eb43d36408a9626 to your computer and use it in GitHub Desktop.
Save ryanflorence/cde19eb43d36408a9626 to your computer and use it in GitHub Desktop.
// built files are found at /public/__build__/*
// how do I get `webpack` to build to `public/__build__/`
// but have the webpack dev server serve `public/index.html`
// and the bundles from `/__build__/`?
//
// I'm using this to run the server
//
// webpack-dev-server --inline --content-base public/
//
// and this is my config:
var webpack = require('webpack');
module.exports = {
entry: {
app: './app/main.js',
vendor: ['react', 'react-router']
},
output: {
filename: 'public/__build__/app.js'
},
module: {
loaders: [
{test: /\.js$/, loader: 'jsx-loader?harmony&insertPragma=React.DOM'}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendor', 'public/__build__/vendor.js')
]
};
@akiran
Copy link

akiran commented Nov 17, 2014

var webpack = require('webpack');
var path = require('path');

module.exports = {
  entry: {
    app: './app/main.js',
    vendor: ['react', 'react-router']
  },
  // create app.js and vendor.js in './public/__build__' 
  output: {
    path: path.join(__dirname, 'public', '__build__'),
    filename: '[name].js',
  },
  module: {
    loaders: [
      {test: /\.js$/, loader: 'jsx-loader?harmony&insertPragma=React.DOM'}
    ]
  },
  // create common.js with common chunks in app.js, vendor.js
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('common.js', ['vendor', 'app'])
  ]
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment