Skip to content

Commit 5cd5f6f

Browse files
committed
fix: compat with null-loader (close #1239)
1 parent a3af6b3 commit 5cd5f6f

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

lib/loaders/pitcher.js

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ module.exports.pitch = function (remainingRequest) {
1212
const query = qs.parse(this.resourceQuery.slice(1))
1313
const loaders = this.loaders.slice(1) // remove self
1414

15+
// do not inject if user uses null-loader to void the type (#1239)
16+
if (loaders.some(l => /(\/|\\)null-loader/.test(l.path))) {
17+
return
18+
}
19+
1520
// loader.request contains both the resolved loader path and its options
1621
// query (e.g. ??ref-0)
1722
const toLoaderString = loader => loader.request

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"mini-css-extract-plugin": "^0.2.0",
6060
"node-sass": "^4.7.2",
6161
"normalize-newline": "^3.0.0",
62+
"null-loader": "^0.1.1",
6263
"postcss-loader": "^2.1.2",
6364
"pug": "^2.0.1",
6465
"pug-plain-loader": "^1.0.0",

test/edgeCases.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,17 @@ test('html-webpack-plugin', done => {
148148
done()
149149
}, true)
150150
})
151+
152+
test('usage with null-loader', done => {
153+
mockBundleAndRun({
154+
entry: 'basic.vue',
155+
modify: config => {
156+
config.module.rules[1] = {
157+
test: /\.css$/,
158+
use: ['null-loader']
159+
}
160+
}
161+
}, ({ window, exports, code }) => {
162+
done()
163+
})
164+
})

yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -5781,6 +5781,10 @@ nth-check@~1.0.1:
57815781
dependencies:
57825782
boolbase "~1.0.0"
57835783

5784+
null-loader@^0.1.1:
5785+
version "0.1.1"
5786+
resolved "https://registry.yarnpkg.com/null-loader/-/null-loader-0.1.1.tgz#17be9abfcd3ff0e1512f6fc4afcb1f5039378fae"
5787+
57845788
num2fraction@^1.2.2:
57855789
version "1.2.2"
57865790
resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede"

0 commit comments

Comments
 (0)