Skip to content

Instantly share code, notes, and snippets.

@daybrush
Created April 11, 2018 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daybrush/55501109375becfefd096892d49bf666 to your computer and use it in GitHub Desktop.
Save daybrush/55501109375becfefd096892d49bf666 to your computer and use it in GitHub Desktop.
react webpack-dev-server
const fs = require("fs");
const path = require("path");
const webpack = require("webpack");
const WriteFilePlugin = require("write-file-webpack-plugin");
const JS_DR = path.resolve(__dirname, "examples/js");
function buildEntries() {
return fs.readdirSync(JS_DR).reduce((entries, dir) => {
if (dir === "dat.gui.js") {
return entries;
}
entries[dir] = path.join(JS_DR, dir);
return entries;
}, {});
}
module.exports = {
devtool: "inline-source-map",
entry: buildEntries(),
output: {
filename: "[name]",
path: `${__dirname}/examples/build/`,
publicPath: "/exmaples/build/"
},
devServer: {
contentBase: `${__dirname}/examples`,
},
module: {
loaders: [
{
test: /\.js$/,
loader: "babel-loader",
},
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
}),
new WriteFilePlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment