Skip to content

Commit adfaf4a

Browse files
committed
bug #1095 Revert removing public option (louismariegaborit)
This PR was squashed before being merged into the main branch. Discussion ---------- Revert removing public option Add --public option like an encore argument to specify public url that use for entry asset in entrypoints.json. I have a problem with this suggestion when I try to build webpack but the result is correct. Anyone can help me ? <img width="928" alt="Capture d’écran 2022-02-17 à 20 43 09" src="https://user-images.githubusercontent.com/15611563/154558941-411037fb-9d2a-4532-a158-73870a575708.png"> Fixes #1094 Commits ------- 33da174 Revert removing public option
2 parents 9e1528e + 33da174 commit adfaf4a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

bin/encore.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ process.argv.splice(2, 1);
3333
const encoreOnlyArguments = new Set(['--keep-public-path']);
3434
process.argv = process.argv.filter(arg => !encoreOnlyArguments.has(arg));
3535

36+
// remove argument --public not supported by webpack/dev-server
37+
const indexPublicArgument = process.argv.indexOf('--public');
38+
if (indexPublicArgument !== -1) {
39+
process.argv.splice(indexPublicArgument, 2);
40+
}
41+
3642
if (!runtimeConfig.isValidCommand) {
3743
if (runtimeConfig.command) {
3844
console.log(chalk.bgRed.white(`Invalid command "${runtimeConfig.command}"`));
@@ -78,6 +84,7 @@ function showUsageInstructions() {
7884
console.log(` - ${chalk.yellow('--host')} The hostname/ip address the webpack-dev-server will bind to`);
7985
console.log(` - ${chalk.yellow('--port')} The port the webpack-dev-server will bind to`);
8086
console.log(` - ${chalk.yellow('--keep-public-path')} Do not change the public path (it is usually prefixed by the dev server URL)`);
87+
console.log(` - ${chalk.yellow('--public')} The public url for entry asset in entrypoints.json`);
8188
console.log(' - Supports any webpack-dev-server options');
8289
console.log();
8390
console.log(` ${chalk.green('production')} : runs webpack for production`);

lib/config/parse-runtime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module.exports = function(argv, cwd) {
4444
runtimeConfig.devServerHttps = argv.https;
4545
runtimeConfig.devServerKeepPublicPath = argv.keepPublicPath || false;
4646

47-
if (typeof argv['client-web-socket-url'] === 'string') {
48-
runtimeConfig.devServerPublic = argv['client-web-socket-url'];
47+
if (typeof argv.public === 'string') {
48+
runtimeConfig.devServerPublic = argv.public;
4949
}
5050

5151
runtimeConfig.devServerHost = argv.host ? argv.host : 'localhost';

test/config/parse-runtime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ describe('parse-runtime', () => {
9393
expect(config.devServerHttps).to.equal(true);
9494
});
9595

96-
it('dev-server command client-web-socket-url', () => {
96+
it('dev-server command public', () => {
9797
const testDir = createTestDirectory();
98-
const config = parseArgv(createArgv(['dev-server', '--client-web-socket-url', 'https://my-domain:8080']), testDir);
98+
const config = parseArgv(createArgv(['dev-server', '--public', 'https://my-domain:8080']), testDir);
9999

100100
expect(config.devServerPublic).to.equal('https://my-domain:8080');
101101
});

0 commit comments

Comments
 (0)