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cesContent":["import * as Path from 'path';\nimport * as FS from 'fs-extra';\n\nimport { Component, RendererComponent } from '../components';\nimport { RendererEvent } from '../events';\nimport { Renderer } from '../renderer';\n\n/**\n * A plugin that copies the subdirectory ´assets´ from the current themes\n * source folder to the output directory.\n */\n@Component({name: 'assets'})\nexport class AssetsPlugin extends RendererComponent {\n /**\n * Should the default assets always be copied to the output directory?\n */\n copyDefaultAssets = true;\n\n /**\n * Create a new AssetsPlugin instance.\n */\n initialize() {\n this.listenTo(this.owner, {\n [RendererEvent.BEGIN]: this.onRendererBegin\n });\n }\n\n /**\n * Triggered before the renderer starts rendering a project.\n *\n * @param event An event object describing the current render operation.\n */\n private onRendererBegin(event: RendererEvent) {\n let fromDefault: string | undefined = Path.join(Renderer.getDefaultTheme(), 'assets');\n const to = Path.join(event.outputDirectory, 'assets');\n\n if (this.copyDefaultAssets) {\n FS.copySync(fromDefault, to);\n } else {\n fromDefault = undefined;\n }\n\n const from = Path.join(this.owner.theme!.basePath, 'assets');\n if (from !== fromDefault && FS.existsSync(from)) {\n FS.copySync(from, to);\n }\n }\n}\n"]}
\No newline at end of file