Skip to content

Instantly share code, notes, and snippets.

@jtulk
Created March 29, 2017 15:37
Show Gist options
  • Save jtulk/7cf5ffd95714f7548e4ba7ec10327cb0 to your computer and use it in GitHub Desktop.
Save jtulk/7cf5ffd95714f7548e4ba7ec10327cb0 to your computer and use it in GitHub Desktop.
Configuration for Babel-Loader Error When Specifying --env
{
"scripts": {
"build:prod": "webpack --env=prod --colors --profile --json > prod.stats.json",
"build:staging": "webpack --env=dev --colors --profile --json > staging.stats.json",
"start": "webpack-dev-server --env=dev --open --watch --progress",
}
}
function buildConfig(env) {
return require(`./config/webpack.${env}.config.js`)(env)
}
module.exports = buildConfig;
const path = require("path");
const webpack = require("webpack");
module.exports = function(env) {
return {
entry: "./src/app/app.js",
output: {
path: path.resolve(__dirname, "staging/js"),
publicPath: "js/",
filename: `app.js`,
sourceMapFilename: `app.map.js`
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [path.resolve(__dirname, "src")],
exclude: [
path.resolve(__dirname, "src/js"),
path.resolve(__dirname, "node_modules")
],
loader: "babel-loader",
options: {
presets: ["es2015", "react", "stage-0"],
plugins: [
"transform-async-functions",
"transform-object-rest-spread",
"transform-regenerator"
]
}
}
]
},
devtool: "source-map",
devServer: {
contentBase: "staging",
compress: false,
port: 9000
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment