DimiMikadze / create-react-library

React NPM library starter kit based on Facebook's create react app
MIT License
602 stars 60 forks source link

How to get only index.js without css in build folder #21

Closed theone3nu closed 6 years ago

theone3nu commented 6 years ago

Dimitri, Earlier when i run npm build i used to get only index.js in build folder. But now i am seeing css folder also. Because of this i am unable to build my library. I don't understand my previous create react library still provides build/index.js only. Only when i take latest copy of create react library i am seeing css folder.

DimiMikadze commented 6 years ago

@theone3nu

Yes, in new version we are extracting css from index.js and creating css/index.css file in build folder, that way we can load css faster.

theone3nu commented 6 years ago

@Dimitri

I am trying to convert build/index component to a function so that i can use that component in non react page. ` import ReactDOM from 'react-dom'; import React from 'react'; import Example from '../create-react-library-test/build';

const showChatTemplate = (messages, element) => { ReactDOM.render(, element); };

module.exports = showChatTemplate;` I am building again using webpack i am getting this error

ERROR in ./~/process/browser.js Module build failed: TypeError: fileSystem.statSync is not a function at module.exports (/Users/Trinu/WebstormProjects/create-react-library-test/node_modules/babel-loader/lib/utils/exists.js:7:25) at find (/Users/Trinu/WebstormProjects/create-react-library-test/node_modules/babel-loader/lib/resolve-rc.js:13:9) at Object.module.exports (/Users/Trinu/WebstormProjects/create-react-library-test/node_modules/babel-loader/lib/index.js:113:132) @ ../create-react-library-test/~/react/index.js 1:0-102

ERROR in (webpack)/~/timers-browserify/main.js Module build failed: TypeError: fileSystem.statSync is not a function at module.exports (/Users/Trinu/WebstormProjects/create-react-library-test/node_modules/babel-loader/lib/utils/exists.js:7:25) at find (/Users/Trinu/WebstormProjects/create-react-library-test/node_modules/babel-loader/lib/resolve-rc.js:13:9) at Object.module.exports (/Users/Trinu/WebstormProjects/create-react-library-test/node_modules/babel-loader/lib/index.js:113:132) @ ../create-react-library-test/build/index.js 1:0-130 1:0-130

With Earlier version i didn't get this error. Can you please help me on how to fix this. Thanks

DimiMikadze commented 6 years ago

@theone3nu i don't understand what you've mean by I am trying to convert build/index component to a function ? build/index is a production built of your library as well as all it's dependencies, not a component only.

Regarding error message, i don't know what it's about.

theone3nu commented 6 years ago

Resolved changed babel version to 7.1.1 from 7.1.2 and that error got resolved.

theone3nu commented 6 years ago

@DimitriMikadze Can you please tell where i have to change inorder to get everything in index.js without css please?

DimiMikadze commented 6 years ago

@theone3nu you have to make changes inside Webpack configuration files.