Skip to content

Commit

Permalink
fix: don't panic when code-splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jan 25, 2019
1 parent 268b82e commit 63c1a8d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,23 @@ export default (options = {}) => {
async generateBundle(opts, bundle) {
if (extracted.size === 0) return

// TODO: support `[hash]`
const dir = opts.dir || path.dirname(opts.file)
const file =
opts.file ||
path.join(
opts.dir,
Object.keys(bundle).find(fileName => bundle[fileName].isEntry)
)
const getExtracted = () => {
const fileName =
typeof postcssLoaderOptions.extract === 'string' ?
path.relative(dir, postcssLoaderOptions.extract) :
`${path.basename(opts.file, path.extname(opts.file))}.css`
`${path.basename(file, path.extname(file))}.css`
const concat = new Concat(true, fileName, '\n')
const entries = Array.from(extracted.values())
const { modules } = bundle[path.relative(dir, opts.file)]
const { modules } = bundle[path.relative(dir, file)]

if (modules) {
const fileList = Object.keys(modules)
entries.sort(
Expand Down

0 comments on commit 63c1a8d

Please sign in to comment.