Skip to content
Permalink
Browse files

fix: support no assetFileNames configuration (#448)

Fixes #447
  • Loading branch information...
tivac committed Jul 12, 2018
1 parent 073019c commit 9e495dcbe53dc8f0443f06b56338d9b00db5d870
@@ -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
);
}

@@ -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 {
@@ -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({

0 comments on commit 9e495dc

Please sign in to comment.
You can’t perform that action at this time.