Skip to content

Commit

Permalink
Removed minify option
Browse files Browse the repository at this point in the history
  • Loading branch information
bezoerb committed Jun 3, 2021
1 parent a5faf64 commit 86aaa4a
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 42 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"postcss-discard": "^1.0.1",
"postcss-image-inliner": "^4.0.4",
"postcss-url": "^10.1.3",
"prettier": "^2.2.1",
"replace-ext": "^2.0.0",
"slash": "^3.0.0",
"tempy": "^1.0.1",
Expand Down
4 changes: 1 addition & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const DEFAULT = {
height: 900,
timeout: 30000,
maxImageFileSize: 10240,
minify: true,
inline: false,
strict: false,
extract: false,
Expand All @@ -31,7 +30,6 @@ const schema = Joi.object()
ignore: [Joi.array(), Joi.object().unknown(true)],
width: Joi.number().default(DEFAULT.width),
height: Joi.number().default(DEFAULT.height),
minify: Joi.boolean().default(DEFAULT.minify),
dimensions: Joi.array().items({width: Joi.number(), height: Joi.number()}),
inline: [Joi.boolean().default(DEFAULT.inline), Joi.object().unknown(true)],
maxImageFileSize: Joi.number().default(DEFAULT.maxImageFileSize),
Expand Down Expand Up @@ -103,7 +101,7 @@ function getOptions(options = {}) {
value.inline = Boolean(inline) && {
minify: value.minify,
basePath: value.base || process.cwd(),
...(inline === true ? {} : inline),
...(inline === true ? {strategy: 'media'} : inline),
};

if (value.inline.replaceStylesheets !== undefined && !Array.isArray(value.inline.replaceStylesheets)) {
Expand Down
3 changes: 1 addition & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const pAll = require('p-all');
const debug = require('debug')('critical:core');
const postcss = require('postcss');
const discard = require('postcss-discard');
const prettier = require('prettier');
const imageInliner = require('postcss-image-inliner');
const penthouse = require('penthouse');
const {PAGE_UNLOADED_DURING_EXECUTION_ERROR_MESSAGE} = require('penthouse/lib/core');
Expand Down Expand Up @@ -178,7 +177,7 @@ async function create(options = {}) {
}

// Minify or prettify
criticalCSS = minify ? cleanCSS.minify(criticalCSS).styles : prettier.format(criticalCSS, {parser: 'css'});
criticalCSS = cleanCSS.minify(criticalCSS).styles;

const result = {
css: criticalCSS,
Expand Down
25 changes: 0 additions & 25 deletions test/blackbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ describe('generate (local)', () => {
{
base: FIXTURES_DIR,
src: 'generate-default.html',
minify: true,
target,
width: 1300,
height: 900,
Expand All @@ -306,7 +305,6 @@ describe('generate (local)', () => {
base: FIXTURES_DIR,
src: 'generate-default-nostyle.html',
css: ['fixtures/styles/main.css', 'fixtures/styles/bootstrap.css'],
minify: true,
target,
width: 1300,
height: 900,
Expand Down Expand Up @@ -575,7 +573,6 @@ describe('generate (local)', () => {
base: FIXTURES_DIR,
src: 'generateInline.html',
// destFolder: '.',
minify: true,
target,
inline: true,
},
Expand All @@ -593,7 +590,6 @@ describe('generate (local)', () => {
generate(
{
base: FIXTURES_DIR,
minify: false,
src: 'generateInline.html',
inline: true,
},
Expand All @@ -604,7 +600,6 @@ describe('generate (local)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
src: 'generateInline.html',
inline: true,
},
Expand Down Expand Up @@ -634,7 +629,6 @@ describe('generate (local)', () => {
base: FIXTURES_DIR,
src: 'generateInline-external.html',
inlineImages: false,
minify: true,
target,
inline: true,
},
Expand All @@ -651,7 +645,6 @@ describe('generate (local)', () => {
base: FIXTURES_DIR,
src: 'generateInline-external.html',
inlineImages: false,
minify: true,
extract: true,
target,
inline: true,
Expand All @@ -667,7 +660,6 @@ describe('generate (local)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
src: 'generateInline-svg.html',
target,
inline: true,
Expand All @@ -683,7 +675,6 @@ describe('generate (local)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
extract: true,
src: 'generateInline.html',
target,
Expand All @@ -700,7 +691,6 @@ describe('generate (local)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
extract: true,
html: read('fixtures/generateInline.html'),
target,
Expand Down Expand Up @@ -738,7 +728,6 @@ describe('generate (local)', () => {
src: 'generate-default.html',
target,
ignore: [],
minify: true,
width: 1300,
height: 900,
},
Expand All @@ -756,7 +745,6 @@ describe('generate (local)', () => {
src: 'generate-ignorefont.html',
target,
ignore: ['@font-face'],
minify: true,
width: 1300,
height: 900,
},
Expand Down Expand Up @@ -808,7 +796,6 @@ describe('generate (local)', () => {
height: 1080,
},
],
minify: true,
extract: false,
ignore: ['@font-face', /url\(/],
include: [/^\.main-navigation.*$/, /^\.hero-deck.*$/, /^\.deck.*$/, /^\.search-box.*$/],
Expand Down Expand Up @@ -901,7 +888,6 @@ describe('generate (local)', () => {
base: FIXTURES_DIR,
src: 'issue-395.html',
target,
minify: false,
inline: false,
width: 1300,
height: 900,
Expand All @@ -923,7 +909,6 @@ describe('generate (local)', () => {
base: FIXTURES_DIR,
src: 'issue-415.html',
target,
minify: false,
inline: false,
dimensions,
concurrency: 10,
Expand Down Expand Up @@ -984,7 +969,6 @@ describe('generate (remote)', () => {
{
base: FIXTURES_DIR,
src: `http://localhost:${port}/generate-default.html`,
minify: true,
target,
width: 1300,
height: 900,
Expand All @@ -1002,7 +986,6 @@ describe('generate (remote)', () => {
base: FIXTURES_DIR,
src: `http://localhost:${port}/generate-default-nostyle.html`,
css: ['fixtures/styles/main.css', 'fixtures/styles/bootstrap.css'],
minify: true,
target,
width: 1300,
height: 900,
Expand Down Expand Up @@ -1214,7 +1197,6 @@ describe('generate (remote)', () => {
{
base: FIXTURES_DIR,
src: `http://localhost:${port}/generateInline.html`,
minify: true,
target,
inline: true,
},
Expand All @@ -1241,7 +1223,6 @@ describe('generate (remote)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
src: `http://localhost:${port}/generateInline.html`,
inline: true,
},
Expand All @@ -1267,7 +1248,6 @@ describe('generate (remote)', () => {
base: FIXTURES_DIR,
src: `http://localhost:${port}/generateInline-external2.html`,
inlineImages: false,
minify: true,
target,
inline: true,
},
Expand All @@ -1284,7 +1264,6 @@ describe('generate (remote)', () => {
base: FIXTURES_DIR,
src: `http://localhost:${port}/generateInline-external2.html`,
inlineImages: false,
minify: true,
extract: true,
target,
inline: true,
Expand All @@ -1300,7 +1279,6 @@ describe('generate (remote)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
src: `http://localhost:${port}/generateInline-svg.html`,
target,
inline: true,
Expand All @@ -1316,7 +1294,6 @@ describe('generate (remote)', () => {
generate(
{
base: FIXTURES_DIR,
minify: true,
extract: true,
src: `http://localhost:${port}/generateInline.html`,
target,
Expand Down Expand Up @@ -1354,7 +1331,6 @@ describe('generate (remote)', () => {
src: `http://localhost:${port}/generate-default.html`,
target,
ignore: [],
minify: true,
width: 1300,
height: 900,
},
Expand All @@ -1372,7 +1348,6 @@ describe('generate (remote)', () => {
src: `http://localhost:${port}/generate-ignorefont.html`,
target,
ignore: ['@font-face'],
minify: true,
width: 1300,
height: 900,
},
Expand Down
3 changes: 0 additions & 3 deletions test/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test('Returns config object', () => {
width: DEFAULT.width,
height: DEFAULT.height,
maxImageFileSize: DEFAULT.maxImageFileSize,
minify: DEFAULT.minify,
strict: DEFAULT.strict,
extract: DEFAULT.extract,
concurrency: DEFAULT.concurrency,
Expand All @@ -57,14 +56,12 @@ test('Target config on passed string', () => {

test('Inline config on passed boolean', () => {
expect(getOptions({src: '...', inline: true, base: 'BASE'})).toHaveProperty('inline', {
minify: DEFAULT.minify,
basePath: 'BASE',
});
});

test('Inline config on passed object', () => {
expect(getOptions({src: '...', inline: {check: true}, base: 'BASE'})).toHaveProperty('inline', {
minify: DEFAULT.minify,
basePath: 'BASE',
check: true,
});
Expand Down
1 change: 0 additions & 1 deletion test/core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ test('Generate critical-path CSS', async () => {
try {
const result = await create({
src: `http://localhost:${port}/generate-default.html`,
minify: true,
});
expect(result.css).toBe(css);
expect(result.html).toBe(html);
Expand Down
2 changes: 0 additions & 2 deletions test/expected/.tmp.css

This file was deleted.

5 changes: 0 additions & 5 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ test('#192 - include option - stream', (done) => {
const critical = stream({
base: path.join(__dirname, 'fixtures'),
css: ['fixtures/styles/issue-192.css'],
minify: true,
extract: false,
ignore: ['@font-face', /url\(/],
dimensions: [
Expand Down Expand Up @@ -318,7 +317,6 @@ test('issue 341', async () => {

const options = {
base: path.join(__dirname, 'fixtures'),
minify: true,
extract: false,
inline: false,
dimensions: [
Expand Down Expand Up @@ -353,7 +351,6 @@ test('Replace stylesheet on extract-target', async () => {
html: read('fixtures/generate-adaptive.html'),
base: path.join(__dirname, 'fixtures'),
target: {uncritical: target},
minify: true,
extract: true,
inline: true,
});
Expand All @@ -368,7 +365,6 @@ test('Remove stylesheet on empty uncritical css', async () => {
const result = await generate({
html: read('fixtures/issue-304.html'),
base: path.join(__dirname, 'fixtures'),
minify: true,
extract: true,
inline: true,
});
Expand All @@ -382,7 +378,6 @@ test('Use async cb result for inline.replaceStylesheets', async () => {
const result = await generate({
html: read('fixtures/issue-304.html'),
base: path.join(__dirname, 'fixtures'),
minify: true,
extract: true,
inline: {
replaceStylesheets: cb,
Expand Down

0 comments on commit 86aaa4a

Please sign in to comment.