22
33const Command = require ( '../models/command' ) ;
44const Win = require ( '../utilities/windows-admin' ) ;
5+ const SilentError = require ( 'silent-error' ) ;
6+
7+ const ClassicOptions = [
8+ { name : 'watch' , type : Boolean , default : false , aliases : [ 'w' ] } ,
9+ { name : 'watcher' , type : String } ,
10+ ] ;
511
612module . exports = Command . extend ( {
713 name : 'build' ,
8- description : 'Builds your app and places it into the output path (dist/ by default) .' ,
14+ description : 'Vestigial command in Vite-based projects. Use the `build` script from package.json instead .' ,
915 aliases : [ 'b' ] ,
1016
1117 availableOptions : [
@@ -16,13 +22,42 @@ module.exports = Command.extend({
1622 aliases : [ 'e' , { dev : 'development' } , { prod : 'production' } ] ,
1723 description : 'Possible values are "development", "production", and "test".' ,
1824 } ,
19- { name : 'output-path' , type : 'Path' , default : 'dist/' , aliases : [ 'o' ] } ,
20- { name : 'watch' , type : Boolean , default : false , aliases : [ 'w' ] } ,
21- { name : 'watcher' , type : String } ,
2225 { name : 'suppress-sizes' , type : Boolean , default : false } ,
26+ { name : 'output-path' , type : 'Path' , default : 'dist/' , aliases : [ 'o' ] } ,
2327 ] ,
2428
29+ init ( ) {
30+ this . _super . apply ( this , arguments ) ;
31+ if ( ! this . isViteProject ) {
32+ this . description = 'Builds your app and places it into the output path (dist/ by default).' ;
33+ this . availableOptions = this . availableOptions . concat ( ClassicOptions ) ;
34+ } else if ( process . env . EMBROIDER_PREBUILD ) {
35+ // having the --watch option available surpresses a warning that you get in Vite prebuild
36+ this . availableOptions = this . availableOptions . concat ( ClassicOptions [ 0 ] ) ;
37+ }
38+ } ,
39+
2540 async run ( commandOptions ) {
41+ if ( this . isViteProject && ! process . env . EMBROIDER_PREBUILD ) {
42+ // --watch is used during Embroider prebuild but should never be used directly so we only throw in this case if
43+ // EMBROIDER_PREBUILD has been set
44+ if ( commandOptions . watch ) {
45+ return Promise . reject (
46+ new SilentError (
47+ 'The `--watch` option to `ember build` is not supported in Vite-based projects. Please use `vite dev` instead.'
48+ )
49+ ) ;
50+ }
51+
52+ if ( commandOptions . watcher ) {
53+ return Promise . reject (
54+ new SilentError (
55+ 'The `--watcher` option to `ember build` is not supported in Vite-based projects. Please use `vite dev` instead.'
56+ )
57+ ) ;
58+ }
59+ }
60+
2661 await Win . checkIfSymlinksNeedToBeEnabled ( this . ui ) ;
2762
2863 let buildTaskName = commandOptions . watch ? 'BuildWatch' : 'Build' ;
0 commit comments