From 2c6996b2e486838a20caaf13939678a6f2fa5d4b Mon Sep 17 00:00:00 2001 From: Levin Rickert Date: Sun, 4 Mar 2018 13:56:25 +0100 Subject: [PATCH] cleanup --- .babelrc | 15 --------------- publish/package.json | 4 ++-- rollup.config.js | 21 ++++++++++++++++----- scripts/generate.js | 16 ++++++++-------- 4 files changed, 26 insertions(+), 30 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 18dd975..0000000 --- a/.babelrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "presets": [ - [ - "es2015", - { - "modules": false - } - ], - "react" - ], - "plugins": [ - "transform-object-rest-spread", - "external-helpers" - ] -} diff --git a/publish/package.json b/publish/package.json index 32e7883..131286b 100644 --- a/publish/package.json +++ b/publish/package.json @@ -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" diff --git a/rollup.config.js b/rollup.config.js index 00f10ac..9d4eba9 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,5 @@ import { readdirSync } from 'fs'; import { resolve } from 'path'; - import babel from 'rollup-plugin-babel'; const listOfEnties = readdirSync(resolve(__dirname, './build')); @@ -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', }, { @@ -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 } -}) +}); diff --git a/scripts/generate.js b/scripts/generate.js index 9f678af..6d34dea 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -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}\`; @@ -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