(resolver)
| 47 | class ProductResolverPlugin { |
| 48 | // Imports foo.coco.bar, foo.ozar.bar, or foo.bar as appropriate |
| 49 | apply(resolver) { |
| 50 | resolver.ensureHook(this.target) |
| 51 | |
| 52 | resolver |
| 53 | .getHook("undescribed-raw-file") |
| 54 | .tapAsync('ProductResolver', (request, ctx, cb) => { |
| 55 | cb() |
| 56 | }) |
| 57 | |
| 58 | resolver |
| 59 | .getHook("resolveStep") |
| 60 | .tap('ProductResolver', function(hook, request) { |
| 61 | if (/node_modules/.test(request.path)) return |
| 62 | |
| 63 | if (!request.relativePath) return |
| 64 | |
| 65 | if (/\.import\.(sass|scss)$/.test(request.path)) { |
| 66 | request.path = request.path.replace(/\.import\.(sass|scss)/, `.${productSuffix}.$1`) |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | let match = request.path.match(new RegExp(`([a-z]+)\\.${productSuffix}\\.\\1$`)) |
| 71 | if (!match) return |
| 72 | let fixed = request.path.substr(0, match.index) + productSuffix + '.' + match[1] |
| 73 | request.path = fixed |
| 74 | }) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // Main webpack config |
no outgoing calls
no test coverage detected