Skip to content

Commit

Permalink
feat(core): Add rollup-plugin-svg (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanirilli authored and evocateur committed Oct 10, 2018
1 parent fca3af8 commit 92ce567
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/pectin-core/lib/getPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const json = require('rollup-plugin-json');
const nodeResolve = require('rollup-plugin-node-resolve');
const mainEntry = require('rollup-plugin-main-entry');
const subpathExternals = require('rollup-plugin-subpath-externals');
const svg = require('rollup-plugin-svg');
const babelrc = require('@pectin/babelrc');

module.exports = async function getPlugins(pkg) {
Expand All @@ -28,5 +29,7 @@ module.exports = async function getPlugins(pkg) {
babel(rc),
// https://github.com/rollup/rollup-plugin-commonjs#usage
commonjs(),
// https://github.com/antony/rollup-plugin-svg
svg(),
];
};
3 changes: 2 additions & 1 deletion packages/pectin-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-main-entry": "file:../rollup-plugin-main-entry",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-subpath-externals": "file:../rollup-plugin-subpath-externals"
"rollup-plugin-subpath-externals": "file:../rollup-plugin-subpath-externals",
"rollup-plugin-svg": "^1.0.1"
}
}
12 changes: 10 additions & 2 deletions packages/pectin-core/test/__snapshots__/pectin-core.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
exports[`pectin-core integration: cjs 1`] = `
"'use strict';
function foo() {}
var svgTest = 'data:image/svg+xml;base64,dGVzdDs=';
function foo() {
return svgTest;
}
module.exports = foo;
"
`;

exports[`pectin-core integration: esm 1`] = `
"function foo() {}
"var svgTest = 'data:image/svg+xml;base64,dGVzdDs=';
function foo() {
return svgTest;
}
export default foo;
"
Expand Down
6 changes: 5 additions & 1 deletion packages/pectin-core/test/pectin-core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('pectin-core', () => {
expect.objectContaining({ name: 'json' }),
expect.objectContaining({ name: 'babel' }),
expect.objectContaining({ name: 'commonjs' }),
expect.objectContaining({ name: 'svg' }),
],
});
});
Expand Down Expand Up @@ -175,7 +176,10 @@ describe('pectin-core', () => {
},
}),
src: Dir({
'index.js': File('export default function foo() {};'),
'test.svg': File(`test`),
'index.js': File(
`import svgTest from './test.svg'; export default function foo() { return svgTest; };`
),
}),
});
const pkgPath = path.join(cwd, 'package.json');
Expand Down

0 comments on commit 92ce567

Please sign in to comment.