Created
June 6, 2016 22:48
-
-
Save jaseflow/20bb6246381084d65b65a558ff74cdfb 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
| var path = require("path"), | |
| webpack = require("webpack"), | |
| merge = require("merge"), | |
| config = require("./config/config"), | |
| ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
| var webpackConfig = { | |
| output: { | |
| path: path.join(__dirname, "dist"), | |
| filename: "bundle.js", | |
| publicPath: "/static/" | |
| }, | |
| plugins: [ | |
| new webpack.optimize.OccurenceOrderPlugin(), | |
| new webpack.NoErrorsPlugin() | |
| ] | |
| }; | |
| var sassLoaders = [ | |
| "css-loader", | |
| "sass-loader?includePaths[]=" + path.resolve(__dirname, "./src/styles") | |
| ]; | |
| if (config.name === "Production") { | |
| webpackConfig = merge(webpackConfig,{ | |
| devtool: "source-map", | |
| entry : [ | |
| "./src/client/index.js" | |
| ], | |
| module: { | |
| loaders: [ | |
| { | |
| test: /\.js$/, | |
| loader: "babel", | |
| exclude: /node_modules/, | |
| include: __dirname | |
| }, | |
| { test: /\.(png|jpg|gif|jpeg)$/, loader: "url-loader?limit=8192"}, | |
| { test: /\.scss$/, loader: ExtractTextPlugin.extract("style-loader", sassLoaders.join("!")) } | |
| ] | |
| }, | |
| plugins : [ | |
| new webpack.DefinePlugin({ | |
| "process.env": { | |
| NODE_ENV: JSON.stringify("prod") | |
| } | |
| }), | |
| new webpack.optimize.UglifyJsPlugin({minimize: true}), | |
| new ExtractTextPlugin("styles.css") | |
| ] | |
| }); | |
| } else { | |
| webpackConfig = merge(webpackConfig, { | |
| devtool: "#inline-source-map", | |
| module: { | |
| loaders: [{ | |
| test: /\.js$/, | |
| loader: "babel", | |
| exclude: /node_modules/, | |
| include: __dirname, | |
| query: { | |
| optional: ["runtime"], | |
| stage: 2, | |
| env: { | |
| development: { | |
| plugins: [ | |
| "react-transform" | |
| ], | |
| extra: { | |
| "react-transform": { | |
| transforms: [{ | |
| transform: "react-transform-hmr", | |
| imports: ["react"], | |
| locals: ["module"] | |
| }, | |
| { | |
| transform: "react-transform-catch-errors", | |
| imports: ["react","redbox-react" ] | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| { | |
| test: /\.(png|jpg|gif|jpeg)$/, | |
| loader: "url-loader?limit=8192"}, | |
| { | |
| test: /\.scss$/, | |
| loaders: ["style", "css", "sass"] } | |
| ]}, | |
| entry : [ | |
| "webpack-hot-middleware/client", | |
| "./src/client/index.js" | |
| ], | |
| plugins : [ | |
| new webpack.HotModuleReplacementPlugin() | |
| ] | |
| }); | |
| } | |
| module.exports = webpackConfig; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment