Skip to content

Commit

Permalink
fix: support no assetFileNames configuration (#448)
Browse files Browse the repository at this point in the history
Fixes #447
  • Loading branch information
tivac authored Jul 12, 2018
1 parent 073019c commit 9e495dc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/rollup/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,17 @@ module.exports = function(opts) {
const usage = new Map();
const common = new Map();
const files = [];

const { assetFileNames = "" } = outputOptions;

let to;

if(!outputOptions.file && !outputOptions.dir) {
to = path.join(process.cwd(), outputOptions.assetFileNames || "");
to = path.join(process.cwd(), assetFileNames);
} else {
to = path.join(
outputOptions.dir ? outputOptions.dir : path.dirname(outputOptions.file),
outputOptions.assetFileNames
assetFileNames
);
}

Expand Down
8 changes: 8 additions & 0 deletions packages/rollup/test/__snapshots__/rollup.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ Object {
}
`;
exports[`/rollup.js should handle assetFileNames being undefined 1`] = `
"/* packages/rollup/test/specimens/simple.css */
.fooga {
color: red;
}
"
`;
exports[`/rollup.js should not output sourcemaps when they are disabled 1`] = `
"/* packages/rollup/test/specimens/simple.css */
.fooga {
Expand Down
21 changes: 21 additions & 0 deletions packages/rollup/test/rollup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ describe("/rollup.js", () => {

expect(read("css/assets/simple.css")).toMatchSnapshot();
});

it("should handle assetFileNames being undefined", async () => {
const bundle = await rollup({
input : require.resolve("./specimens/simple.js"),
plugins : [
plugin({
namer,
map,
}),
],
});

await bundle.write({
format,
file : `${output}/assetFileNames/simple.js`,
});

const [ css ] = shell.ls(`${output}/assetFileNames/assets`);

expect(read(`assetFileNames/assets/${css}`)).toMatchSnapshot();
});

it("should correctly pass to/from params for relative paths", async () => {
const bundle = await rollup({
Expand Down

0 comments on commit 9e495dc

Please sign in to comment.