mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Generalize minifier (#2577)
This commit is contained in:
parent
1ffeace8f9
commit
5a6d537d43
7
config/.eslintrc.json
Normal file
7
config/.eslintrc.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../.eslintrc.json",
|
||||
"rules": {
|
||||
"import/no-extraneous-dependencies": 0,
|
||||
"global-require": 0
|
||||
}
|
||||
}
|
29
config/minimizer.js
Normal file
29
config/minimizer.js
Normal file
@ -0,0 +1,29 @@
|
||||
const BabelMinifyPlugin = require("babel-minify-webpack-plugin");
|
||||
|
||||
module.exports.minimizer = [
|
||||
// Took options from Polymer build tool
|
||||
// https://github.com/Polymer/tools/blob/master/packages/build/src/js-transform.ts
|
||||
new BabelMinifyPlugin(
|
||||
{
|
||||
// Disable the minify-constant-folding plugin because it has a bug relating
|
||||
// to invalid substitution of constant values into export specifiers:
|
||||
// https://github.com/babel/minify/issues/820
|
||||
evaluate: false,
|
||||
|
||||
// TODO(aomarks) Find out why we disabled this plugin.
|
||||
simplifyComparisons: false,
|
||||
|
||||
// Prevent removal of things that babel thinks are unreachable, but sometimes
|
||||
// gets wrong: https://github.com/Polymer/tools/issues/724
|
||||
deadcode: false,
|
||||
|
||||
// Disable the simplify plugin because it can eat some statements preceeding
|
||||
// loops. https://github.com/babel/minify/issues/824
|
||||
simplify: false,
|
||||
|
||||
// This is breaking ES6 output. https://github.com/Polymer/tools/issues/261
|
||||
mangle: false,
|
||||
},
|
||||
{}
|
||||
),
|
||||
];
|
@ -1,9 +1,9 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||
const WorkboxPlugin = require("workbox-webpack-plugin");
|
||||
const { babelLoaderConfig } = require("../config/babel.js");
|
||||
const { minimizer } = require("../config/babel.js");
|
||||
|
||||
const isProd = process.env.NODE_ENV === "production";
|
||||
const chunkFilename = isProd ? "chunk.[chunkhash].js" : "[name].chunk.js";
|
||||
@ -39,6 +39,9 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimizer,
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
__DEV__: false,
|
||||
@ -69,19 +72,10 @@ module.exports = {
|
||||
},
|
||||
]),
|
||||
isProd &&
|
||||
new UglifyJsPlugin({
|
||||
extractComments: true,
|
||||
sourceMap: true,
|
||||
uglifyOptions: {
|
||||
// Disabling because it broke output
|
||||
mangle: false,
|
||||
},
|
||||
new WorkboxPlugin.GenerateSW({
|
||||
swDest: "service_worker_es5.js",
|
||||
importWorkboxFrom: "local",
|
||||
}),
|
||||
// isProd &&
|
||||
new WorkboxPlugin.GenerateSW({
|
||||
swDest: "service_worker_es5.js",
|
||||
importWorkboxFrom: "local",
|
||||
}),
|
||||
].filter(Boolean),
|
||||
resolve: {
|
||||
extensions: [".ts", ".js", ".json"],
|
||||
|
@ -1,7 +1,7 @@
|
||||
const path = require("path");
|
||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||
const { babelLoaderConfig } = require("../config/babel.js");
|
||||
const { minimizer } = require("../config/babel.js");
|
||||
|
||||
const isProd = process.env.NODE_ENV === "production";
|
||||
const chunkFilename = isProd ? "chunk.[chunkhash].js" : "[name].chunk.js";
|
||||
@ -32,6 +32,9 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimizer,
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([
|
||||
"public",
|
||||
|
@ -1,7 +1,7 @@
|
||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
||||
const CompressionPlugin = require("compression-webpack-plugin");
|
||||
const config = require("./config.js");
|
||||
const { babelLoaderConfig } = require("../config/babel.js");
|
||||
const { minimizer } = require("../config/babel.js");
|
||||
|
||||
const isProdBuild = process.env.NODE_ENV === "production";
|
||||
const isCI = process.env.CI === "true";
|
||||
@ -27,16 +27,10 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimizer,
|
||||
},
|
||||
plugins: [
|
||||
isProdBuild &&
|
||||
new UglifyJsPlugin({
|
||||
extractComments: true,
|
||||
sourceMap: true,
|
||||
uglifyOptions: {
|
||||
// Disabling because it broke output
|
||||
mangle: false,
|
||||
},
|
||||
}),
|
||||
isProdBuild &&
|
||||
!isCI &&
|
||||
new CompressionPlugin({
|
||||
|
@ -1,7 +1,6 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const BabelMinifyPlugin = require("babel-minify-webpack-plugin");
|
||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||
const WorkboxPlugin = require("workbox-webpack-plugin");
|
||||
const CompressionPlugin = require("compression-webpack-plugin");
|
||||
@ -9,6 +8,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const zopfli = require("@gfx/zopfli");
|
||||
const translationMetadata = require("./build-translations/translationMetadata.json");
|
||||
const { babelLoaderConfig } = require("./config/babel.js");
|
||||
const { minimizer } = require("./config/minimizer.js");
|
||||
|
||||
const version = fs.readFileSync("setup.py", "utf8").match(/\d{8}\.\d+/);
|
||||
if (!version) {
|
||||
@ -77,29 +77,7 @@ function createConfig(isProdBuild, latestBuild) {
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
// Took options from Polymer build tool
|
||||
// https://github.com/Polymer/tools/blob/master/packages/build/src/js-transform.ts
|
||||
new BabelMinifyPlugin(
|
||||
{
|
||||
// Disable the minify-constant-folding plugin because it has a bug relating to
|
||||
// invalid substitution of constant values into export specifiers:
|
||||
// https://github.com/babel/minify/issues/820
|
||||
evaluate: false,
|
||||
|
||||
// TODO(aomarks) Find out why we disabled this plugin.
|
||||
simplifyComparisons: false,
|
||||
|
||||
// Disable the simplify plugin because it can eat some statements preceeding
|
||||
// loops. https://github.com/babel/minify/issues/824
|
||||
simplify: false,
|
||||
|
||||
// This is breaking ES6 output. https://github.com/Polymer/tools/issues/261
|
||||
mangle: false,
|
||||
},
|
||||
{}
|
||||
),
|
||||
],
|
||||
minimizer,
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
|
Loading…
x
Reference in New Issue
Block a user