Skip to content

Commit a6d9608

Browse files
Merge branch 'master' into patch-2
2 parents 555533a + 1be21d2 commit a6d9608

File tree

12 files changed

+105
-2
lines changed

12 files changed

+105
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"test:only": "cross-env NODE_ENV=test jest",
3232
"test:watch": "npm run test:only -- --watch",
3333
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
34-
"test:manual": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
34+
"test:manual": "npm run build && webpack serve ./test/manual/src/index.js --open --config ./test/manual/webpack.config.js",
3535
"pretest": "npm run lint",
3636
"test": "cross-env NODE_ENV=test npm run test:coverage",
3737
"defaults": "webpack-defaults"

src/loader.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,22 @@ export function pitch(request) {
5050
const childFilename = '*';
5151
const publicPath =
5252
typeof options.publicPath === 'string'
53-
? options.publicPath === '' || options.publicPath.endsWith('/')
53+
? options.publicPath === 'auto'
54+
? ''
55+
: options.publicPath === '' || options.publicPath.endsWith('/')
5456
? options.publicPath
5557
: `${options.publicPath}/`
5658
: typeof options.publicPath === 'function'
5759
? options.publicPath(this.resourcePath, this.rootContext)
60+
: this._compilation.outputOptions.publicPath === 'auto'
61+
? ''
5862
: this._compilation.outputOptions.publicPath;
63+
5964
const outputOptions = {
6065
filename: childFilename,
6166
publicPath,
6267
};
68+
6369
const childCompiler = this._compilation.createChildCompiler(
6470
`${pluginName} ${request}`,
6571
outputOptions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
background: red;
3+
background-image: url(c9e192c015437a21dea1faa1d30f4941.svg);
4+
}
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './style.css';
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
background: red;
3+
background-image: url(./react.svg);
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Self from '../../../src';
2+
3+
module.exports = {
4+
entry: './index.js',
5+
output: {
6+
publicPath: 'auto',
7+
},
8+
module: {
9+
rules: [
10+
{
11+
test: /\.css$/,
12+
use: [
13+
{
14+
loader: Self.loader,
15+
options: {},
16+
},
17+
'css-loader',
18+
],
19+
},
20+
{
21+
test: /\.(svg|png)$/,
22+
use: [
23+
{
24+
loader: 'file-loader',
25+
options: {
26+
filename: '[name].[ext]',
27+
},
28+
},
29+
],
30+
},
31+
],
32+
},
33+
plugins: [
34+
new Self({
35+
filename: '[name].css',
36+
}),
37+
],
38+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
background: red;
3+
background-image: url(c9e192c015437a21dea1faa1d30f4941.svg);
4+
}
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './style.css';
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
background: red;
3+
background-image: url(./react.svg);
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Self from '../../../src';
2+
3+
module.exports = {
4+
entry: './index.js',
5+
module: {
6+
rules: [
7+
{
8+
test: /\.css$/,
9+
use: [
10+
{
11+
loader: Self.loader,
12+
options: {
13+
publicPath: 'auto',
14+
},
15+
},
16+
'css-loader',
17+
],
18+
},
19+
{
20+
test: /\.(svg|png)$/,
21+
use: [
22+
{
23+
loader: 'file-loader',
24+
options: {
25+
filename: '[name].[ext]',
26+
},
27+
},
28+
],
29+
},
30+
],
31+
},
32+
plugins: [
33+
new Self({
34+
filename: '[name].css',
35+
}),
36+
],
37+
};

0 commit comments

Comments
 (0)