Skip to content

Test source map and contenthash #1171

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

Merged
merged 18 commits into from
Aug 21, 2020
Merged
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
Next Next commit
test: output source map
  • Loading branch information
alexander-akait committed Aug 21, 2020
commit 3bcfd578024b5b66a5cd7c383825dbb8b5ace539
43 changes: 43 additions & 0 deletions test/__snapshots__/sourceMap-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,49 @@ Array [

exports[`"sourceMap" option true should generate source maps and do not change "[contenthash]" on different platform: warnings 1`] = `Array []`;

exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: errors 1`] = `Array []`;

exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: extracted css 1`] = `
".nested {
color: blue;
}

.class {
color: red;
}


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

exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: source map 1`] = `
Object {
"file": "main.xxxxxxxxxxxxxxxxxxxx.css",
"mappings": "AAAA;EACE,WAAW;AACb;;ACAA;EACE,UAAU;AACZ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"webpack:///test/fixtures/source-map/nested/nested.css",
"webpack:///test/fixtures/source-map/basic.css",
],
"sourcesContent": Array [
".nested {
color: blue;
}
",
"@import \\"./nested/nested.css\\";

.class {
color: red;
}
",
],
"version": 3,
}
`;

exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: warnings 1`] = `Array []`;

exports[`"sourceMap" option true should generate source maps when css was extracted: errors 1`] = `Array []`;

exports[`"sourceMap" option true should generate source maps when css was extracted: extracted css 1`] = `
Expand Down
10 changes: 7 additions & 3 deletions test/sourceMap-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,16 @@ describe('"sourceMap" option', () => {
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it.skip('should generate source maps when css was extracted and do not change "[contenthash]" on different platform', async () => {
it('should generate source maps when css was extracted and do not change "[contenthash]" on different platform', async () => {
const compiler = getCompiler(
'./source-map/basic.js',
{},
{
devtool: 'source-map',
// webpack@4 has bug
// It uses readableIdentifier to generate the sources, which uses the RequestShortener,
// which has some problems with paths that are 2 folders above the context
context: path.resolve(__dirname, '..'),
output: {
path: path.resolve(__dirname, '../outputs'),
filename: '[name].bundle.js',
Expand Down Expand Up @@ -526,8 +530,8 @@ describe('"sourceMap" option', () => {

expect(chunkName).toBe(
webpack.version[0] === '5'
? 'main.93ca7a8226bf6b9e8275.css'
: 'main.7232fe75dbf29c350324.css'
? 'main.8189c1c4f956dd69079a.css'
: 'main.6aa45a5434fd0e992559.css'
);

expect(
Expand Down