Skip to content

Commit

Permalink
Applied some prettier magic.
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Dec 17, 2018
1 parent 2c34b21 commit 4eae10c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ async function processStyle(id, fileDest, keepName) {
})

await fs.outputFile(fileDest, result.css)
await fs.outputFile(fileDest + ".map", result.map)
await fs.outputFile(`${fileDest}.map`, result.map)
}

export default function rebase(options = {}) {
const { include, exclude = defaultExclude, verbose = false, keepName = false, folder = "" } = options
const {
include,
exclude = defaultExclude,
verbose = false,
keepName = false,
folder = ""
} = options

const filter = createFilter(include, exclude)
const wrappers = {}
Expand Down Expand Up @@ -103,15 +109,19 @@ export default function rebase(options = {}) {
const fileSource = path.resolve(path.dirname(importer), importee)
const fileName = path.basename(importee, fileExt)
const fileHash = await getHash(fileSource)
const fileTarget = keepName ? `${fileName}_${fileHash}${fileExt}` : `${fileHash}${fileExt}`
const fileTarget = keepName ?
`${fileName}_${fileHash}${fileExt}` :
`${fileHash}${fileExt}`

// Registering for our copying job when the bundle is created (kind of a job queue)
// and respect any sub folder given by the configuration options.
files[fileSource] = path.join(folder, fileTarget)

// Replacing slashes for Windows, as we need to use POSIX style to be compat
// to Rollup imports / NodeJS resolve implementation.
const assetId = path.join(path.dirname(importer), folder, fileTarget).replace(/\\/g, "/")
const assetId = path
.join(path.dirname(importer), folder, fileTarget)
.replace(/\\/g, "/")
const resolvedId = `${assetId}.js`

// Register asset for exclusion handling in this function.
Expand Down Expand Up @@ -169,7 +179,7 @@ export default function rebase(options = {}) {
}
})
)
} catch(error) {
} catch (error) {
throw new Error("Error while copying files:", error)
}
}
Expand Down

0 comments on commit 4eae10c

Please sign in to comment.