Skip to content

Next #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed

Next #760

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: mini css extract plugin
  • Loading branch information
alexander-akait committed Oct 31, 2018
commit 829d7d55ce9597fb238954fd82807fdfbf646199
23 changes: 17 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"jest": "^23.4.0",
"lint-staged": "^7.2.0",
"memory-fs": "^0.4.1",
"mini-css-extract-plugin": "^0.4.4",
"sass": "^1.14.3",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.0.6",
Expand Down
80 changes: 80 additions & 0 deletions test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,86 @@ exports.locals = { foo: \\"bar\\", bar: \\"foo\\" };

exports[`loader message api: warnings 1`] = `Array []`;

exports[`loader using together with "MiniCssExtractPlugin": errors 1`] = `Array []`;

exports[`loader using together with "MiniCssExtractPlugin": extracted 1`] = `
".foo {
color: red;
}

@charset \\"UTF-8\\";

.class {
color: red;
background: url(5b1f36bc41ab31f5b801d48ba1d65781.png);
}

.class-duplicate-url {
background: url(5b1f36bc41ab31f5b801d48ba1d65781.png);
}

.u-m\\\\+ {
a: b c d;
}

.grid.\\\\-top {
a: b c d;
}

.u-m\\\\00002b {
a: b c d;
}

.class {
content: '\\"\\\\\\\\f10c\\"';
}

.class {
font-family: '微软雅黑';
}

.class {
content: '\\\\e901';
}

.class {
content: \\"\\\\F10C\\"
}

.class {
content: \\"\\\\f10C\\"
}

.class {
content: \\"\\\\F10C \\\\F10D\\"
}

:root {
--foo: 1px;
--bar: 2px;
}

:root {
--title-align: center;
--sr-only: {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip: rect(0,0,0,0);
white-space: nowrap;
clip-path: inset(50%);
border: 0;
};
}


/*# sourceMappingURL=main.css.map*/"
`;

exports[`loader using together with "MiniCssExtractPlugin": warnings 1`] = `Array []`;

exports[`loader using together with "postcss-loader" (reuse ast): errors 1`] = `Array []`;

exports[`loader using together with "postcss-loader" (reuse ast): module (evaluated) 1`] = `
Expand Down
42 changes: 42 additions & 0 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';

import postcss from 'postcss';
import postcssPresetEnv from 'postcss-preset-env';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';

import webpack from './helpers/compiler';
import evaluated from './helpers/evaluated';
Expand Down Expand Up @@ -266,4 +267,45 @@ describe('loader', () => {
);
expect(normalizeErrors(stats.compilation.errors)).toMatchSnapshot('errors');
});

it('using together with "MiniCssExtractPlugin"', async () => {
const config = {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: path.resolve(__dirname, '../src'),
options: {
importLoaders: 1,
},
},
],
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: {
loader: 'file-loader',
},
},
],
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '[name].css',
chunkFilename: '[id].css',
}),
],
};
const stats = await webpack('basic.js', config);
const extracted = stats.compilation.assets['main.css'];

expect(extracted.source()).toMatchSnapshot('extracted');
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});
});