Created
June 13, 2017 06:01
-
-
Save tejasrsuthar/ce460cd27b280af02a1b7d257aa94903 to your computer and use it in GitHub Desktop.
Sample Webpack configuration
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
"use strict"; | |
var webpack = require("webpack"); | |
var path = require("path"); | |
module.exports = { | |
cache: true, | |
entry: path.join(__dirname, "src/index.js"), | |
externals: [ | |
{ | |
"react": { | |
root: "React", | |
commonjs2: "react", | |
commonjs: "react", | |
amd: "react" | |
}, | |
"react-dom": { | |
root: "ReactDom", | |
commonjs2: "react-dom", | |
commonjs: "react-dom", | |
amd: "react-dom" | |
} | |
} | |
], | |
output: { | |
path: path.join(__dirname, "dist"), | |
filename: "component-playground.min.js", | |
library: "ComponentPlayground", | |
libraryTarget: "umd" | |
}, | |
resolve: { | |
extensions: ["", ".js", ".jsx"] | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
exclude: /(node_modules)/, | |
loader: "babel-loader" | |
}, { | |
test: /\.css$/, | |
loader: "style-loader!css-loader" | |
}, { | |
test: /\.(png|jpg)$/, | |
loader: "url-loader?limit=8192" | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false | |
} | |
}), | |
new webpack.DefinePlugin({ | |
// Signal production, so that webpack removes non-production code that | |
// is in condtionals like: `if (process.env.NODE_ENV === "production")` | |
"process.env.NODE_ENV": JSON.stringify("production") | |
}), | |
new webpack.SourceMapDevToolPlugin("[file].map") | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment