Skip to content
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

feat: add support for none config in dotfolder #1637

Merged
merged 7 commits into from
Jun 30, 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
2 changes: 2 additions & 0 deletions packages/webpack-cli/lib/groups/ConfigGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ const { extensions } = require('interpret');
const GroupHelper = require('../utils/GroupHelper');
const rechoir = require('rechoir');

// Order defines the priority, in increasing order
const DEFAULT_CONFIG_LOC = [
'.webpack/webpack.config',
'.webpack/webpack.config.none',
'.webpack/webpack.config.dev',
'.webpack/webpack.config.prod',
'.webpack/webpackfile',
Expand Down
9 changes: 9 additions & 0 deletions test/config/multiple/all/.webpack/webpack.config.none.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { resolve } = require('path');

module.exports = {
entry: './index.js',
output: {
path: resolve(__dirname, '../binary'),
filename: 'none.bundle.js',
},
};
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
'use strict';
const { stat } = require('fs');
const { resolve } = require('path');
const { run } = require('../../utils/test-utils');
const { resolve, join } = require('path');
const { run } = require('../../../utils/test-utils');
const rimraf = require('rimraf');

const outputPath = join(__dirname, 'binary');

describe('multiple config files', () => {
afterEach(() => rimraf.sync(outputPath));
beforeAll(() => rimraf.sync(outputPath));

it('Uses prod config from dot folder if present', (done) => {
const { stdout, stderr } = run(__dirname, [], false);
expect(stderr).toBeFalsy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { resolve } = require('path');

module.exports = {
entry: './index.js',
output: {
path: resolve(__dirname, '../binary'),
filename: 'dev.bundle.js',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { resolve } = require('path');

module.exports = {
entry: './index.js',
output: {
path: resolve(__dirname, '../binary'),
filename: 'none.bundle.js',
},
};
23 changes: 23 additions & 0 deletions test/config/multiple/none and dev/dev-none-config.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
const { stat } = require('fs');
const { resolve, join } = require('path');
const { run } = require('../../../utils/test-utils');
const rimraf = require('rimraf');

const outputPath = join(__dirname, 'binary');

describe('multiple config files', () => {
afterEach(() => rimraf.sync(outputPath));
beforeAll(() => rimraf.sync(outputPath));

it('Uses dev config when both dev and none are present', (done) => {
const { stdout, stderr } = run(__dirname, [], false);
expect(stderr).toBeFalsy();
expect(stdout).not.toBe(undefined);
stat(resolve(__dirname, './binary/dev.bundle.js'), (err, stats) => {
expect(err).toBe(null);
expect(stats.isFile()).toBe(true);
done();
});
});
});
1 change: 1 addition & 0 deletions test/config/multiple/none and dev/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Kageyama")