This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const CompressionPlugin = require('compression-webpack-plugin'); | ||
|
||
module.exports = ({devServer}) => !devServer ? new CompressionPlugin({ | ||
test: /\.js$|\.css$|\.html$/, | ||
threshold: 1024 * 10 | ||
}) : null; | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const {promisify} = require('util'); | ||
const index = require('../../loaders'); | ||
|
||
const readDir = promisify(fs.readdir); | ||
|
||
describe('Plugin index', () => { | ||
it('Should return an option for each file in the loaders', async () => { | ||
const files = await readDir(path.join(__dirname, '../../loaders')); | ||
// - 2 because the utils and the index are not included. | ||
expect(Object.keys(index).length).toBe(files.length - 2); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const compress = require('../../plugins/compress'); | ||
|
||
describe('Compression plugin', () => { | ||
const defaults = { | ||
options: { | ||
test: /\.js$|\.css$|\.html$/, | ||
threshold: 1024 * 10 | ||
}, | ||
}; | ||
|
||
it('should return the plugin with default values', () => { | ||
expect(compress({})).toMatchObject(defaults); | ||
}); | ||
|
||
describe('receives an options object to customize the config', () => { | ||
it('allows to enable devServer and disable compression', () => { | ||
expect(compress({devServer: true})).toBe(null); | ||
}); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const {promisify} = require('util'); | ||
const index = require('../../plugins'); | ||
|
||
const readDir = promisify(fs.readdir); | ||
|
||
describe('Plugin index', () => { | ||
it('Should return an option for each file in the plugins', async () => { | ||
const files = await readDir(path.join(__dirname, '../../plugins')); | ||
expect(Object.keys(index).length).toBe(files.length - 1); | ||
}); | ||
}); |