Better dev server integration

This commit is contained in:
MICHAEL JACKSON
2018-02-16 16:00:06 -08:00
parent a22e0fa801
commit d6f2bc089a
42 changed files with 1753 additions and 1154 deletions

View File

@ -1,18 +1,15 @@
const path = require("path")
const webpack = require("webpack")
const HTMLWebpackPlugin = require("html-webpack-plugin")
const CopyWebpackPlugin = require("copy-webpack-plugin")
const path = require("path");
const webpack = require("webpack");
module.exports = {
devtool: process.env.NODE_ENV === "production" ? false : "cheap-module-source-map",
entry: {
client: path.resolve(__dirname, "client/index.js")
main: path.resolve(__dirname, "client/main.js")
},
output: {
path: path.resolve(__dirname, "build"),
filename: "[name]-[hash:8].js"
filename: "[name]-[hash:8].js",
path: path.resolve(__dirname, "public/_assets"),
publicPath: "/_assets/"
},
module: {
@ -20,32 +17,18 @@ module.exports = {
{ test: /\.js$/, exclude: /node_modules/, use: ["babel-loader"] },
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
{ test: /\.md$/, use: ["html-loader", "markdown-loader"] },
{ test: /\.png/, use: ["file-loader"] }
{ test: /\.png$/, use: ["file-loader"] }
]
},
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development")
}),
new HTMLWebpackPlugin({
title: "unpkg",
chunks: ["client"],
template: path.resolve(__dirname, "client/index.html")
}),
new CopyWebpackPlugin(["public"])
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "development"
)
})
],
devServer: {
proxy: {
"**": {
target: "http://localhost:8081",
bypass: req => {
if (req.path === "/") {
return "/"
}
}
}
}
}
}
devtool:
process.env.NODE_ENV === "production" ? false : "cheap-module-source-map"
};