Minify postcss parser (#6395)
* Update webpack to v4 * add todo * add link * Minify postcss parser * update yarn.lock * chore: update yarn.lockmaster
parent
8d0ac8bb58
commit
71d9a08488
|
@ -114,6 +114,7 @@
|
|||
"snapshot-diff": "0.4.0",
|
||||
"strip-ansi": "4.0.0",
|
||||
"tempy": "0.2.1",
|
||||
"terser-webpack-plugin": "1.4.1",
|
||||
"webpack": "4.39.1"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -99,7 +99,7 @@ async function run(params) {
|
|||
await execa("rm", ["-rf", ".cache"]);
|
||||
}
|
||||
|
||||
const bundleCache = new Cache(".cache/", "v14");
|
||||
const bundleCache = new Cache(".cache/", "v15");
|
||||
await bundleCache.load();
|
||||
|
||||
console.log(chalk.inverse(" Building packages "));
|
||||
|
|
|
@ -159,7 +159,7 @@ function getWebpackConfig(bundle) {
|
|||
}
|
||||
|
||||
const root = path.resolve(__dirname, "..", "..");
|
||||
return {
|
||||
const config = {
|
||||
entry: path.resolve(root, bundle.input),
|
||||
module: {
|
||||
rules: [
|
||||
|
@ -179,14 +179,22 @@ function getWebpackConfig(bundle) {
|
|||
libraryTarget: "umd",
|
||||
// https://github.com/webpack/webpack/issues/6642
|
||||
globalObject: 'new Function("return this")()'
|
||||
},
|
||||
optimization: {
|
||||
// TODO: enable this
|
||||
// `parser-postcss.js` can't work with terser
|
||||
// https://github.com/prettier/prettier/pull/6200#issuecomment-500018106
|
||||
minimize: false
|
||||
}
|
||||
};
|
||||
|
||||
if (bundle.terserOptions) {
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
|
||||
config.optimization = {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: bundle.terserOptions
|
||||
})
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function runWebpack(config) {
|
||||
|
|
|
@ -15,6 +15,7 @@ const PROJECT_ROOT = path.resolve(__dirname, "../..");
|
|||
* @property {string[]} externals - array of paths that should not be included in the final bundle
|
||||
* @property {Object.<string, string>} replace - map of strings to replace when processing the bundle
|
||||
* @property {string[]} babelPlugins - babel plugins
|
||||
* @property {Object?} terserOptions - options for `terser`
|
||||
|
||||
* @typedef {Object} CommonJSConfig
|
||||
* @property {Object} namedExports - for cases where rollup can't infer what's exported
|
||||
|
@ -59,7 +60,13 @@ const parsers = [
|
|||
input: "src/language-css/parser-postcss.js",
|
||||
target: "universal",
|
||||
// postcss has dependency cycles that don't work with rollup
|
||||
bundler: "webpack"
|
||||
bundler: "webpack",
|
||||
// postcss need keep_fnames when minify
|
||||
terserOptions: {
|
||||
mangle: {
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
input: "src/language-graphql/parser-graphql.js",
|
||||
|
|
|
@ -6785,7 +6785,7 @@ tempy@0.2.1:
|
|||
temp-dir "^1.0.0"
|
||||
unique-string "^1.0.0"
|
||||
|
||||
terser-webpack-plugin@^1.4.1:
|
||||
terser-webpack-plugin@1.4.1, terser-webpack-plugin@^1.4.1:
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz#61b18e40eaee5be97e771cdbb10ed1280888c2b4"
|
||||
integrity sha512-ZXmmfiwtCLfz8WKZyYUuuHf3dMYEjg8NrjHMb0JqHVHVOSkzp3cW2/XG1fP3tRhqEqSzMwzzRQGtAPbs4Cncxg==
|
||||
|
|
Loading…
Reference in New Issue