Skip to content

Commit ef83382

Browse files
committed
Automatically detect buildTarget
1 parent aabdc35 commit ef83382

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,22 @@ module.exports = {
3232
this._super.included.apply(this, arguments);
3333

3434
// If this is set, show a warning
35-
let buildTarget = includer.options &&
35+
let explicitBuildTarget = includer.options &&
3636
includer.options[this.name] &&
3737
includer.options[this.name]['buildTarget'];
38+
if (explicitBuildTarget) {
39+
this.ui.writeWarnLine('You no longer need to specify a buildTarget - it is now derived from your project files. Please delete this config option.')
40+
}
3841

39-
// // fs.readdirSync(includer.project.root + '/app/tailwind')
40-
// let buildTarget;
41-
// if (fs.existsSync(includer.project.root + '/app/tailwind')) {
42-
// buildTarget = 'app';
43-
// }
42+
let buildTarget;
43+
if (fs.existsSync(includer.project.root + '/app/tailwind')) {
44+
buildTarget = 'app';
45+
} else if (fs.existsSync(includer.project.root + '/addon/tailwind')) {
46+
buildTarget = 'addon';
47+
} else if (fs.existsSync(includer.project.root + '/tests/dummy/app/tailwind')) {
48+
buildTarget = 'dummy';
49+
}
4450

45-
debugger;
4651
if (!this._validateBuildTarget(buildTarget, includer)) {
4752
return;
4853
}

node-tests/build-target-test.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ describe('build target', function() {
3636
it(`builds for applications`, async () => {
3737
loadScenario(input, 'app-with-tailwind');
3838

39-
let app = new EmberApp({}, {
40-
'ember-cli-tailwind': {
41-
buildTarget: 'app'
42-
}
43-
});
39+
let app = new EmberApp();
4440
output = createBuilder(app.toTree());
4541
await output.build();
4642

@@ -52,11 +48,7 @@ describe('build target', function() {
5248
it(`builds for addons`, async () => {
5349
loadScenario(input, 'addon-with-tailwind');
5450

55-
let addon = new EmberAddon({}, {
56-
'ember-cli-tailwind': {
57-
buildTarget: 'addon'
58-
}
59-
});
51+
let addon = new EmberAddon();
6052
output = createBuilder(addon.toTree());
6153
await output.build();
6254

@@ -68,11 +60,7 @@ describe('build target', function() {
6860
it(`builds for addon's dummy apps`, async () => {
6961
loadScenario(input, 'dummy-app-with-tailwind');
7062

71-
let addon = new EmberAddon({}, {
72-
'ember-cli-tailwind': {
73-
buildTarget: 'dummy'
74-
}
75-
});
63+
let addon = new EmberAddon();
7664
output = createBuilder(addon.toTree());
7765
await output.build();
7866

0 commit comments

Comments
 (0)