@@ -198,21 +198,14 @@ const EMBER_ADDON: AddonImplementation<CSSBlocksApplicationAddon> = {
198198 let env = this . env ! ;
199199
200200 if ( type === "css" ) {
201- if ( ! env . isApp || env . config . broccoliConcat === "SKIP" ) {
201+ if ( ! env . isApp || env . config . broccoliConcat === false ) {
202202 return tree ;
203203 }
204204
205- // Merge default concat options with the options provided by the app.
206- let concatOptions : BroccoliConcatOptions = Object . assign (
207- { } ,
208- buildDefaultBroccoliConcatOptions ( env ) ,
209- env . config . broccoliConcat || { } ,
210- ) ;
211-
212205 // Create the concatenated file...
213206 const concatTree = broccoliConcat (
214207 tree ,
215- concatOptions ,
208+ buildBroccoliConcatOptions ( env ) ,
216209 ) ;
217210
218211 // Then overwrite the original file with our final build artifact.
@@ -224,19 +217,55 @@ const EMBER_ADDON: AddonImplementation<CSSBlocksApplicationAddon> = {
224217 } ,
225218} ;
226219
220+ /**
221+ * Merge together default and user-provided config options to build the
222+ * configuration for broccoli-concat.
223+ * @param env - The current addon environment. Includes override configs.
224+ * @returns - Merged broccoli concat settings.
225+ */
226+ function buildBroccoliConcatOptions ( env : AddonEnvironment ) : BroccoliConcatOptions {
227+ const overrides = env . config . broccoliConcat || { } ;
228+ // The sourcemap config requires special handling because
229+ // things break if extensions or mapCommentType is incorrect.
230+ // We force these to use specific values, but defer to the
231+ // provided options for all other properties.
232+ let sourceMapConfig ;
233+ sourceMapConfig = Object . assign (
234+ { } ,
235+ {
236+ enabled : true ,
237+ } ,
238+ overrides . sourceMapConfig ,
239+ {
240+ extensions : [ "css" ] ,
241+ mapCommentType : "block" ,
242+ } ,
243+ ) ;
244+ // Merge, preferring the user provided options, except for
245+ // the sourceMapConfig, which we merged above.
246+ return Object . assign (
247+ { } ,
248+ buildDefaultBroccoliConcatOptions ( env ) ,
249+ env . config . broccoliConcat ,
250+ {
251+ sourceMapConfig,
252+ } ,
253+ ) ;
254+ }
255+
227256/**
228257 * Build a default broccoli-concat config, using given enviroment settings.
229258 * @param env - The addon environment.
230259 * @returns - Default broccoli-concat options, accounting for current env settings.
231260 */
232261function buildDefaultBroccoliConcatOptions ( env : AddonEnvironment ) : BroccoliConcatOptions {
262+ const cssBlocksOutputFilename = env . config . output || "css-blocks.css" ;
233263 return {
234- inputFiles : [ " assets/css-blocks.css" , `assets/${ env . modulePrefix } .css` ] ,
264+ inputFiles : [ ` assets/${ cssBlocksOutputFilename } ` , `assets/${ env . modulePrefix } .css` ] ,
235265 outputFile : `assets/${ env . modulePrefix } .css` ,
236266 sourceMapConfig : {
237267 enabled : true ,
238268 extensions : [ "css" ] ,
239- inline : true ,
240269 mapCommentType : "block" ,
241270 } ,
242271 } ;
0 commit comments