Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

node-modules CSS files #95

Open
Zaitsev opened this issue Oct 23, 2017 · 3 comments
Open

node-modules CSS files #95

Zaitsev opened this issue Oct 23, 2017 · 3 comments

Comments

@Zaitsev
Copy link

Zaitsev commented Oct 23, 2017

Im tring to use react-select component. This component uses its own css
recommended way to use this component is

import Select from 'react-select';                   
import "react-select/dist/react-select.css";         

Bu I got error

XXX/node_modules\react-select\dist\react-select.css:8 Uncaught SyntaxError: Unexpected token .
    at createScript (vm.js:53)
    at Object.runInThisContext (vm.js:95)
    at Module._compile (module.js:543)
    at Object.Module._extensions..js (module.js:580)
    at Module.load (module.js:488)
    at tryModuleLoad (module.js:447)
    at Function.Module._load (module.js:439)
    at Module.require (module.js:498)
    at require (internal/module.js:20)
    at u (app.tsx:26)

I believe it is caused by .instructions('> [index.tsx] + fuse-box-css')
So external css files missed to CSSPlugin and imported as Javascript files
May be we have to create css-bundle for such files?

@skellock
Copy link
Owner

Hmm... good question. Do you know if react-select is pre-compiled? Many libs in the react community aren't.

If it isn't, then we're going to have to send it thru the babel gauntlet as well, which this stack isn't setup to do.

What does line 8 look like in react-select.css?

If it's just plain ol css, then there's something definitely wrong on my end.

@Zaitsev
Copy link
Author

Zaitsev commented Nov 4, 2017

Sorry for delay: was on vacation....
react-select.css is a pure CSS file. line 8 is a first css line (1-7 are comments)

.Select {
  position: relative;
}
.Select,
.Select div,
.Select input,
.Select span {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

I managad to solve isuue by creating bundle, but it seems not very react-way.

fuse.ts:

    const appGlobalStyles = [
        [/global\.scss$/,
            SassPlugin(),
            CSSPlugin()
        ],
    ];

    const vendorStyles = [
        [/node_modules.*(\.css)$/,
            CSSResourcePlugin({
                dist   : `${OUTPUT_DIR}/vendor`,
                resolve: (f) => `vendor/${f}`
            }),
            CSSPlugin({
                group  : 'vendor-static.css',
                outFile: `${OUTPUT_DIR}/vendor-static.css`
            })
        ],
    ];


    // bundle the electron renderer code
    const rendererBundle = fuse
        .bundle('renderer')
        // .plugin(...moduleCss)
        .plugin(...vendorStyles)
        .plugin(...appGlobalStyles)
        // .plugin(CopyPlugin({useDefault: false, files: ASSETS, dest: 'assets', resolve: 'assets/'}))
        .instructions('> [renderer/index.tsx] + ~renderer/assets/vendorStyles.ts + fuse-box-css')
    ;

vebdorStyles.ts:

import "../../../node_modules/font-awesome/css/font-awesome.css";
import '../../../node_modules/react-select/dist/react-select.css';

And I have to use relative paths in the import othervise css resolves as JS-modules.

@Zaitsev Zaitsev closed this as completed Nov 4, 2017
@Zaitsev Zaitsev reopened this Nov 9, 2017
@Zaitsev
Copy link
Author

Zaitsev commented Nov 9, 2017

incendently closed issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants