Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit 947c2bb

Browse files
committed
[update] use latest extract-test-webpack-plugin to pass all 17 tests
1 parent fe3e64d commit 947c2bb

File tree

2 files changed

+58
-58
lines changed

2 files changed

+58
-58
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"css-loader": "^0.28.10",
3535
"eslint": "^4.18.2",
3636
"eslint-config-google": "^0.9.1",
37-
"extract-text-webpack-plugin": "^3.0.2",
37+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
3838
"file-loader": "^1.1.11",
3939
"html-webpack-plugin": "^3.0.4",
4040
"jasmin": "0.0.2",

test/spec.js

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const webpack = require('webpack');
2323
const HtmlWebpackPlugin = require('html-webpack-plugin');
2424
const PreloadPlugin = require('../');
2525
const OUTPUT_DIR = path.join(__dirname, 'dist');
26-
// const ExtractTextPlugin = require('extract-text-webpack-plugin');
26+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
2727

2828
describe('PreloadPlugin preloads or prefetches async chunks', function() {
2929
it('adds preload tags to async chunks', function(done) {
@@ -375,62 +375,62 @@ describe('PreloadPlugin filters chunks', function() {
375375
});
376376
});
377377

378-
// describe('PreloadPlugin preloads all assets', function() {
379-
// it('adds preload tags', function(done) {
380-
// const compiler = webpack({
381-
// entry: path.join(__dirname, 'fixtures', 'load-css.js'),
382-
// output: {
383-
// path: OUTPUT_DIR,
384-
// filename: 'bundle.js',
385-
// chunkFilename: 'chunk.[chunkhash].js',
386-
// publicPath: '/',
387-
// },
388-
// module: {
389-
// rules: [
390-
// {
391-
// test: /\.css$/,
392-
// loader: ExtractTextPlugin.extract({
393-
// fallback: 'css-loader',
394-
// use: [
395-
// {
396-
// loader: 'css-loader',
397-
// },
398-
// ],
399-
// }),
400-
// },
401-
// {
402-
// test: /\.woff2?$/,
403-
// loader: 'file-loader',
404-
// options: {
405-
// name: '[name].[ext]',
406-
// },
407-
// },
408-
// ],
409-
// },
410-
// plugins: [
411-
// new ExtractTextPlugin({
412-
// filename: 'style.css',
413-
// allChunks: true,
414-
// }),
415-
// new HtmlWebpackPlugin(),
416-
// new PreloadPlugin({
417-
// rel: 'preload',
418-
// include: 'allAssets'
419-
// }),
420-
// ]
421-
// }, function(err, result) {
422-
// expect(err).toBeFalsy();
423-
// expect(JSON.stringify(result.compilation.errors)).toBe('[]');
424-
// const html = result.compilation.assets['index.html'].source();
425-
// expect(html).toContain('<link rel="preload" as="script" href="/chunk');
426-
// expect(html).toContain('<link rel="preload" as="script" href="/bundle.js"');
427-
// expect(html).toContain('<link rel="preload" as="style" href="/style.css"');
428-
// expect(html).toContain('<link rel="preload" as="font" crossorigin="crossorigin" href="/font.woff2"');
429-
// done();
430-
// });
431-
// compiler.outputFileSystem = new MemoryFileSystem();
432-
// });
433-
// });
378+
describe('PreloadPlugin preloads all assets', function() {
379+
it('adds preload tags', function(done) {
380+
const compiler = webpack({
381+
entry: path.join(__dirname, 'fixtures', 'load-css.js'),
382+
output: {
383+
path: OUTPUT_DIR,
384+
filename: 'bundle.js',
385+
chunkFilename: 'chunk.[chunkhash].js',
386+
publicPath: '/',
387+
},
388+
module: {
389+
rules: [
390+
{
391+
test: /\.css$/,
392+
loader: ExtractTextPlugin.extract({
393+
fallback: 'css-loader',
394+
use: [
395+
{
396+
loader: 'css-loader',
397+
},
398+
],
399+
}),
400+
},
401+
{
402+
test: /\.woff2?$/,
403+
loader: 'file-loader',
404+
options: {
405+
name: '[name].[ext]',
406+
},
407+
},
408+
],
409+
},
410+
plugins: [
411+
new ExtractTextPlugin({
412+
filename: 'style.css',
413+
allChunks: true,
414+
}),
415+
new HtmlWebpackPlugin(),
416+
new PreloadPlugin({
417+
rel: 'preload',
418+
include: 'allAssets'
419+
}),
420+
]
421+
}, function(err, result) {
422+
expect(err).toBeFalsy();
423+
expect(JSON.stringify(result.compilation.errors)).toBe('[]');
424+
const html = result.compilation.assets['index.html'].source();
425+
expect(html).toContain('<link rel="preload" as="script" href="/chunk');
426+
expect(html).toContain('<link rel="preload" as="script" href="/bundle.js"');
427+
expect(html).toContain('<link rel="preload" as="style" href="/style.css"');
428+
expect(html).toContain('<link rel="preload" as="font" crossorigin="crossorigin" href="/font.woff2"');
429+
done();
430+
});
431+
compiler.outputFileSystem = new MemoryFileSystem();
432+
});
433+
});
434434

435435
describe('filtering unwanted files', function() {
436436
it('does not include map files to be preloaded', function(done) {

0 commit comments

Comments
 (0)