-
-
Notifications
You must be signed in to change notification settings - Fork 384
add support for webpack's new contenthash support #59
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
body { background: red; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
body { background: green; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './style.css'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
body { background: red; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
body { background: green; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const Self = require('../../../'); | ||
|
||
module.exports = [1, 2].map(n => ({ | ||
entry: './index.js', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
Self.loader, | ||
'css-loader', | ||
], | ||
}, | ||
], | ||
}, | ||
output: { | ||
filename: `${n}.[name].js` | ||
}, | ||
resolve: { | ||
alias: { | ||
'./style.css': `./style${n}.css` | ||
} | ||
}, | ||
plugins: [ | ||
new Self({ | ||
filename: `${n}.[name].[contenthash].css`, | ||
}), | ||
], | ||
})); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[ | ||
/* 0 */, | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
// extracted by mini-css-extract-plugin | ||
module.exports = {"a":"wX52cuPepLZcpDx5S3yYO"}; | ||
|
||
/***/ }) | ||
]]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.wX52cuPepLZcpDx5S3yYO { background: red; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The double hashes in the filename look scary 🤔 I assume that actual users will want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes of course, this is just a test which tests both |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.wX52cuPepLZcpDx5S3yYO { background: green; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import(/* webpackChunkName: "style" */'./style.css'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function(source) { | ||
const { number } = this.query; | ||
return source.split(/\r?\n/)[number-1]; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.a { background: red; } | ||
.a { background: green; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const Self = require('../../../'); | ||
|
||
module.exports = [1, 2].map(n => ({ | ||
entry: './index.js', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
Self.loader, | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: true, | ||
}, | ||
}, | ||
{ | ||
loader: './loader', | ||
ident: 'my-loader', | ||
options: { | ||
number: n | ||
} | ||
} | ||
], | ||
}, | ||
], | ||
}, | ||
output: { | ||
filename: `[name].[contenthash].js` | ||
}, | ||
plugins: [ | ||
new Self({ | ||
filename: `[name].[contenthash].[chunkhash].css`, | ||
}), | ||
], | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.slice
or.substring
?.substr
is Annex B so it'd be better to avoid it entirely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it to
substring
.