Created
April 11, 2018 05:15
-
-
Save daybrush/55501109375becfefd096892d49bf666 to your computer and use it in GitHub Desktop.
react webpack-dev-server
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 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