Open al-ani opened 8 years ago
I include additional libraries in the webpack config entry main for development and production. ( I use this for js, haven't tried it with css)
entry: { 'main': [ 'bootstrap-loader/extractStyles', 'font-awesome-webpack!./src/theme/font-awesome.config.prod.js', './src/client.js', './src/lib/xyz/xyz.js' ] },
or
I create a new folder src/lib
I put all the libraries used in this folder and exclude the folder for jsx loader in webpack config module loaders jsx (for development and production).
{ test: /.jsx?$/, exclude: /(node_modules)|(src\/lib)/, loaders: [strip.loader('debug'), 'babel']},
Then I simply include the js and css files in client.js ( I use this method for 3rd party css too).
import './lib/lib.js'; import 'lib/lib.css';
or you can require where you want to use it
const thisLib = require('../../lib/thisLib/thisLib.js'); thisLib.doStuff();
By doing this you have to make sure you use the relevant javascript in client only not server. Most libraries need a dom element etc which won't be accessible in server. I normally initiate the library in componentDidMount and use them on client side events.
you can import your scss or css to 'src/theme/bootstrap.overrides.scss' like this @import 'style.css'; all of them will add to your project.
I am a totally new to webpack and react, anyway, I am trying to add theme AdminLTE https://github.com/almasaeed2010/AdminLTE So I added the CSS and javascript files to /src/helpers/Html.js , but it is not working :( Any idea how to add external theme :) or how can I add the CSS and js files to the template
-Html.js file