Created
April 2, 2018 09:04
-
-
Save wizardnet972/4989748942479f8dd6de472e9759972a 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 CopyWebpackPlugin = require('copy-webpack-plugin') | |
| const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
| const HtmlWebPackPlugin = require("html-webpack-plugin"); | |
| const HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin'); | |
| const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); | |
| const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); | |
| const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
| const HtmlWebpackCriticalPlugin = require('html-webpack-critical-plugin'); | |
| const OfflinePlugin = require('offline-plugin'); | |
| module.exports = { | |
| mode: 'production', | |
| entry: { | |
| vendor: ["jquery", "lodash", "fullpage.js", "animejs", "smooth-scrollbar"], | |
| main: './app/index.js', | |
| // offline: './app/offline.js' | |
| // main: './app/index.js', | |
| // worker: './app/app.worker.js' | |
| }, | |
| output: { | |
| filename: '[name].[hash].js' | |
| }, | |
| module: { | |
| rules: [ | |
| // { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }, | |
| { | |
| test: /\.css$/, | |
| use: [ | |
| MiniCssExtractPlugin.loader, | |
| { | |
| loader: 'css-loader', | |
| options: { | |
| url: false, | |
| sourceMap: true | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| test: /\.scss$/, | |
| use: [ | |
| MiniCssExtractPlugin.loader, | |
| { | |
| loader: 'css-loader', | |
| options: { | |
| url: false, | |
| sourceMap: true | |
| } | |
| }, | |
| { | |
| loader: 'sass-loader', | |
| options: { | |
| sourceMap: true | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| test: /\.html$/, | |
| use: [{ | |
| loader: "html-loader", | |
| options: { | |
| minimize: true | |
| } | |
| }] | |
| }, | |
| { | |
| test: /\.(png|svg|jpg|gif)$/, | |
| use: [ | |
| 'file-loader' | |
| ] | |
| }, | |
| { | |
| test: /\.svg$/, | |
| loader: 'svg-inline-loader' | |
| }, | |
| { | |
| test: /\.ejs$/, | |
| loader: 'ejs-loader', | |
| }, | |
| // { | |
| // test: /\.(eot|svg|ttf|woff|woff2)$/, | |
| // loader: 'file?name=public/fonts/[name].[ext]' | |
| // } | |
| ] | |
| }, | |
| optimization: { | |
| splitChunks: { | |
| cacheGroups: { | |
| vendor: { | |
| chunks: 'initial', | |
| test: 'vendor', | |
| name: 'vendor', | |
| enforce: true | |
| }, | |
| styles: { | |
| name: 'styles', | |
| test: /\.css$/, | |
| chunks: 'all', | |
| enforce: true | |
| } | |
| } | |
| }, | |
| minimizer: [ | |
| new UglifyJsPlugin({ | |
| cache: true, | |
| parallel: true, | |
| sourceMap: true // set to true if you want JS source maps | |
| }), | |
| new OptimizeCSSAssetsPlugin({}) | |
| ] | |
| }, | |
| plugins: [ | |
| new CleanWebpackPlugin(['dist']), | |
| new CopyWebpackPlugin([{ | |
| from: 'assets', | |
| to: 'assets' | |
| }]), | |
| new HtmlWebPackPlugin({ | |
| template: '!!ejs-compiled-loader!index.ejs', | |
| title: 'Shlomi Levi', | |
| favicon: './assets/favicon.ico', | |
| minify: { | |
| removeComments: true, | |
| collapseWhitespace: true | |
| } | |
| }), | |
| new MiniCssExtractPlugin({ | |
| filename: "[name].[hash].css", | |
| chunkFilename: "[id].[hash].css" | |
| }), | |
| new HtmlWebpackInlineSVGPlugin({ | |
| runPreEmit: true | |
| }), | |
| new HtmlWebpackCriticalPlugin(), | |
| // new OfflinePlugin({ | |
| // caches: 'all', | |
| // ServiceWorker: { | |
| // minify: false | |
| // } | |
| // }), | |
| ] | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment