From 506ed4578742b68d4dc0e2dde1efa768de713bd6 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 10 Aug 2018 20:04:45 -0500 Subject: [PATCH] Revert "revert webpack config to initial" This reverts commit 62b9bb58f0e70754132b6a3ae395fcea8e91a95a. --- src/FilterLists.Web/webpack.config.js | 27 ++++++++++++++------ src/FilterLists.Web/webpack.config.vendor.js | 14 +++++----- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/FilterLists.Web/webpack.config.js b/src/FilterLists.Web/webpack.config.js index 659d35dc9..909a953b6 100644 --- a/src/FilterLists.Web/webpack.config.js +++ b/src/FilterLists.Web/webpack.config.js @@ -12,7 +12,7 @@ module.exports = (env) => { entry: { 'main': "./ClientApp/boot.tsx" }, resolve: { extensions: [".js", ".jsx", ".ts", ".tsx"] }, output: { - path: path.join(window.__dirname, bundleOutputDir), + path: path.join(__dirname, bundleOutputDir), filename: "[name].js", publicPath: "dist/" }, @@ -23,7 +23,16 @@ module.exports = (env) => { test: /\.css$/, use: isDevBuild ? ["style-loader", "css-loader"] - : ExtractTextPlugin.extract({ use: "css-loader?minimize" }) + : ExtractTextPlugin.extract({ + use: [ + { + loader: "css-loader", + options: { + minimize: { discardComments: { removeAll: true } } + } + } + ] + }) }, { test: /\.(png|jpg|jpeg|gif|svg)$/, use: "url-loader?limit=25000" } ] @@ -31,22 +40,24 @@ module.exports = (env) => { plugins: [ new CheckerPlugin(), new webpack.DllReferencePlugin({ - context: window.__dirname, + context: __dirname, manifest: require("./wwwroot/dist/vendor-manifest.json") }) ].concat(isDevBuild ? [ - // Plugins that apply in development builds only new webpack.SourceMapDevToolPlugin({ - filename: "[file].map", // Remove this line if you prefer inline source maps + filename: "[file].map", moduleFilenameTemplate: path.relative(bundleOutputDir, - "[resourcePath]") // Point sourcemap entries to the original file locations on disk + "[resourcePath]") }) ] : [ - // Plugins that apply in production builds only - new webpack.optimize.UglifyJsPlugin(), + new webpack.optimize.UglifyJsPlugin({ + output: { + comments: false + } + }), new ExtractTextPlugin("site.css") ]) } diff --git a/src/FilterLists.Web/webpack.config.vendor.js b/src/FilterLists.Web/webpack.config.vendor.js index 0509cd9c1..499afc9ff 100644 --- a/src/FilterLists.Web/webpack.config.vendor.js +++ b/src/FilterLists.Web/webpack.config.vendor.js @@ -3,7 +3,7 @@ const webpack = require("webpack"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = (env) => { - const extractCss = new ExtractTextPlugin("vendor.css"); + const extractCSS = new ExtractTextPlugin("vendor.css"); const isDevBuild = !(env && env.prod); return [ { @@ -16,7 +16,7 @@ module.exports = (env) => { { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: "url-loader?limit=100000" }, { test: /\.css(\?|$)/, - use: extractCss.extract([isDevBuild ? "css-loader" : "css-loader?minimize"]) + use: extractCSS.extract([isDevBuild ? "css-loader" : "css-loader?minimize"]) } ] }, @@ -24,22 +24,22 @@ module.exports = (env) => { vendor: [ "bootstrap", "bootstrap/dist/css/bootstrap.css", "event-source-polyfill", "isomorphic-fetch", "react", "react-dom", "react-router-dom", "jquery" - ] + ], }, output: { - path: path.join(window.__dirname, "wwwroot", "dist"), + path: path.join(__dirname, "wwwroot", "dist"), publicPath: "dist/", filename: "[name].js", - library: "[name]_[hash]" + library: "[name]_[hash]", }, plugins: [ - extractCss, + extractCSS, new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable) new webpack.DllPlugin({ - path: path.join(window.__dirname, "wwwroot", "dist", "[name]-manifest.json"), + path: path.join(__dirname, "wwwroot", "dist", "[name]-manifest.json"), name: "[name]_[hash]" }), new webpack.DefinePlugin({