|
1 | 1 | import * as webpack from 'webpack';
|
2 | 2 | import * as path from 'path';
|
3 |
| -import { GlobCopyWebpackPlugin } from '../../plugins/glob-copy-webpack-plugin'; |
| 3 | +import * as CopyWebpackPlugin from 'copy-webpack-plugin'; |
4 | 4 | import { NamedLazyChunksWebpackPlugin } from '../../plugins/named-lazy-chunks-webpack-plugin';
|
5 | 5 | import { InsertConcatAssetsWebpackPlugin } from '../../plugins/insert-concat-assets-webpack-plugin';
|
6 |
| -import { extraEntryParser, getOutputHashFormat } from './utils'; |
| 6 | +import { extraEntryParser, getOutputHashFormat, AssetPattern } from './utils'; |
| 7 | +import { isDirectory } from '../../utilities/is-directory'; |
7 | 8 | import { WebpackConfigOptions } from '../webpack-config';
|
8 | 9 |
|
9 | 10 | const ConcatPlugin = require('webpack-concat-plugin');
|
@@ -84,10 +85,37 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
|
84 | 85 |
|
85 | 86 | // process asset entries
|
86 | 87 | if (appConfig.assets) {
|
87 |
| - extraPlugins.push(new GlobCopyWebpackPlugin({ |
88 |
| - patterns: appConfig.assets, |
89 |
| - globOptions: { cwd: appRoot, dot: true, ignore: '**/.gitkeep' } |
90 |
| - })); |
| 88 | + extraPlugins.push(new CopyWebpackPlugin( |
| 89 | + appConfig.assets.map((asset: string | AssetPattern) => { |
| 90 | + // Convert all string assets to object notation. |
| 91 | + asset = typeof asset === 'string' ? { glob: asset } : asset; |
| 92 | + // Add defaults. |
| 93 | + // Input is always resolved relative to the appRoot. |
| 94 | + asset.input = path.resolve(appRoot, asset.input || ''); |
| 95 | + asset.output = asset.output || ''; |
| 96 | + asset.glob = asset.glob || ''; |
| 97 | + |
| 98 | + // Ensure trailing slash. |
| 99 | + if (isDirectory(path.resolve(asset.input))) { |
| 100 | + asset.input += '/'; |
| 101 | + } |
| 102 | + |
| 103 | + // Convert dir patterns to globs. |
| 104 | + if (isDirectory(path.resolve(asset.input, asset.glob))) { |
| 105 | + asset.glob = asset.glob + '/**/*'; |
| 106 | + } |
| 107 | + |
| 108 | + return { |
| 109 | + context: asset.input, |
| 110 | + to: asset.output, |
| 111 | + from: { |
| 112 | + glob: asset.glob, |
| 113 | + dot: true |
| 114 | + } |
| 115 | + }; |
| 116 | + }), |
| 117 | + { ignore: ['.gitkeep'] } |
| 118 | + )); |
91 | 119 | }
|
92 | 120 |
|
93 | 121 | if (buildOptions.progress) {
|
|
0 commit comments