Skip to content

Instantly share code, notes, and snippets.

@gkio
Created June 21, 2017 20:39
Show Gist options
  • Save gkio/6e2f96ab9de77e17cdc00d08d2a31382 to your computer and use it in GitHub Desktop.
Save gkio/6e2f96ab9de77e17cdc00d08d2a31382 to your computer and use it in GitHub Desktop.
const path = require("path");
const merge = require("webpack-merge");
const sass = require("./webpack/sass");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: "./public/index.html",
filename: "index.html",
inject: "body"
});
const PATHS = {
source: path.join(__dirname, "src"),
build: path.join(__dirname, "build")
};
const common = merge([
{
entry: PATHS.source + "/index.js",
output: {
path: PATHS.build,
filename: "main.js"
},
module: {
loaders: [
{
test: /\.js$/,
loader: "babel-loader",
options: {
presets: ["es2015", "react"],
plugins: []
}
}
]
},
plugins: [HtmlWebpackPluginConfig]
}
]);
module.exports = env => {
if (env === "production") return common;
if (env === "development") return merge([common, sass()]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment