Created
May 29, 2018 12:05
-
-
Save macouella/b913607cca3d9bfa2640ce26e1db7373 to your computer and use it in GitHub Desktop.
Somethings gotta give webpack
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
const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); | |
const CopyWebpackPlugin = require("copy-webpack-plugin"); | |
const BrowserSyncPlugin = require("browser-sync-webpack-plugin"); | |
const devMode = process.env.NODE_ENV !== "production"; | |
const path = require("path"); | |
module.exports = { | |
optimization: { | |
minimizer: [ | |
new UglifyJsPlugin({ | |
cache: true, | |
parallel: true | |
// sourceMap: true // set to true if you want JS source maps | |
}), | |
new OptimizeCSSAssetsPlugin({}), | |
new CopyWebpackPlugin([{ from: "./src/img", to: "img" }], {}) | |
] | |
}, | |
entry: { | |
main: "./src", | |
style: "./src/style.sass" | |
}, | |
output: { | |
path: path.resolve(__dirname, "dist/assets") | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.s[a|c]ss$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
"css-loader", | |
{ | |
loader: "sass-loader", | |
options: { | |
indentedSyntax: true | |
} | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin({ | |
// Options similar to the same options in webpackOptions.output | |
// both options are optional | |
filename: "[name].css", | |
chunkFilename: "[id].css" | |
}), | |
new BrowserSyncPlugin( | |
// BrowserSync options | |
{ | |
// browse to http://localhost:3000/ during development | |
host: "localhost", | |
port: 3000, | |
// proxy the Webpack Dev Server endpoint | |
// (which should be serving on http://localhost:8100/) | |
// through BrowserSync | |
proxy: "http://localhost:8100/" | |
} | |
) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment