Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add rollup-plugin-svg #3

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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