Created
June 21, 2017 20:39
-
-
Save gkio/6e2f96ab9de77e17cdc00d08d2a31382 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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