diff --git a/packages/cli/src/build/build.ts b/packages/cli/src/build/build.ts index 45f1cb0a2..f7c1da7bb 100644 --- a/packages/cli/src/build/build.ts +++ b/packages/cli/src/build/build.ts @@ -83,24 +83,7 @@ export async function build( })); } - if (bundled) { - // Polymer 1.x and Polymer 2.x deal with relative urls in dom-module - // templates differently. Polymer CLI will attempt to provide a sensible - // default value for the `rewriteUrlsInTemplates` option passed to - // `polymer-bundler` based on the version of Polymer found in the project's - // folders. We will default to Polymer 1.x behavior unless 2.x is found. - const polymerVersion = await getPolymerVersion(); - const bundlerOptions = { - rewriteUrlsInTemplates: !polymerVersion.startsWith('2.') - }; - if (typeof options.bundle === 'object') { - Object.assign(bundlerOptions, options.bundle); - } - buildStream = buildStream.pipe(polymerProject.bundler(bundlerOptions)); - } - const htmlSplitter = new HtmlSplitter(); - buildStream = pipeStreams([ buildStream, htmlSplitter.split(), @@ -119,6 +102,22 @@ export async function build( htmlSplitter.rejoin() ]); + if (bundled) { + // Polymer 1.x and Polymer 2.x deal with relative urls in dom-module + // templates differently. Polymer CLI will attempt to provide a sensible + // default value for the `rewriteUrlsInTemplates` option passed to + // `polymer-bundler` based on the version of Polymer found in the project's + // folders. We will default to Polymer 1.x behavior unless 2.x is found. + const polymerVersion = await getPolymerVersion(); + const bundlerOptions = { + rewriteUrlsInTemplates: !polymerVersion.startsWith('2.') + }; + if (typeof options.bundle === 'object') { + Object.assign(bundlerOptions, options.bundle); + } + buildStream = buildStream.pipe(polymerProject.bundler(bundlerOptions)); + } + if (options.insertPrefetchLinks) { buildStream = buildStream.pipe(polymerProject.addPrefetchLinks()); }