Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
levrik committed Mar 4, 2018
1 parent 81b613d commit 2c6996b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
15 changes: 0 additions & 15 deletions .babelrc

This file was deleted.

4 changes: 2 additions & 2 deletions publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"design",
"icons"
],
"main": "lib/index.cjs.js",
"module": "lib/index.es.js",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/levrik/mdi-react.git"
Expand Down
21 changes: 16 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readdirSync } from 'fs';
import { resolve } from 'path';

import babel from 'rollup-plugin-babel';

const listOfEnties = readdirSync(resolve(__dirname, './build'));
Expand All @@ -11,7 +10,7 @@ export default listOfEnties.map(entry => {
case 'index.js':
output = [
{
file: resolve(__dirname, './publish/lib/index.cjs.js'),
file: resolve(__dirname, './publish/dist/index.cjs.js'),
format: 'cjs',
},
{
Expand All @@ -32,7 +31,19 @@ export default listOfEnties.map(entry => {
return {
input: resolve(__dirname, './build', entry),
external: ['react'],
plugins: [babel()],
output,
plugins: [babel({
presets: [
[
'es2015',
{ modules: false }
],
'react'
],
plugins: [
'transform-object-rest-spread',
'external-helpers'
]
})],
output
}
})
});
16 changes: 8 additions & 8 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ for (let svgFile of svgFiles) {
// Skip on empty path
if (!path) continue;

const fileName = `${name}Icon.js`;
listOfComponents.push({
name,
fileName,
});
const component = {
name: name + 'Icon',
fileName: name + 'Icon.js'
};
listOfComponents.push(component);

const fileContent =
`import React from 'react';
const ${name}Icon = ({ width = 24, height = 24, viewBox = '0 0 24 24', className, children, ...props }) => {
const ${component.name} = ({ width = 24, height = 24, viewBox = '0 0 24 24', className, children, ...props }) => {
let classes = 'mdi-icon';
if (className) classes += \` \${className}\`;
Expand All @@ -34,10 +34,10 @@ const ${name}Icon = ({ width = 24, height = 24, viewBox = '0 0 24 24', className
);
};
export default ${name}Icon;
export default ${component.name};
`;

fs.writeFileSync(`${__dirname}/../build/${fileName}`, fileContent);
fs.writeFileSync(`${__dirname}/../build/${component.fileName}`, fileContent);
}

const indexFileContent = listOfComponents
Expand Down

0 comments on commit 2c6996b

Please sign in to comment.