Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require("bootstrap/less/bootstrap.less"); #98

Open
oneandonlyonebutyou opened this issue Feb 27, 2020 · 9 comments
Open

require("bootstrap/less/bootstrap.less"); #98

oneandonlyonebutyou opened this issue Feb 27, 2020 · 9 comments

Comments

@oneandonlyonebutyou
Copy link

I am using react with webpack (not create-react-app) and for some reason I cant get

require("bootstrap/less/bootstrap.less");

to work ..
I wonder is this the same as

import 'bootstrap/dist/css/bootstrap.min.css';

please help me set this up.
what I have is ...
image

@sergey-vayser-cherre
Copy link

yes, it's same. make sure you added either bootstrap.css or bootstrap.less to your project and configured webpack to load styles properly

@oneandonlyonebutyou
Copy link
Author

Thank you so much
How am I supposed to "configured webpack to load styles properly" ...
I had

import 'bootstrap/dist/css/bootstrap.min.css';

in my code before ..
how can I make it look as beautiful as the demo? :)

@wwwaiser
Copy link
Owner

@joseph-vedadi It depends of your webpack version. You can find webpack file at this repo and use it as a reference

@oneandonlyonebutyou
Copy link
Author

oneandonlyonebutyou commented Feb 27, 2020

Thank you so much for your help.
Based on my understanding of your comment, the issue is my webpack .

But still, I can't find what I am missing

/* eslint-disable no-console */
const path = require('path')
const BundleTracker = require('webpack-bundle-tracker')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const ReactLoadableSSRAddon = require('react-loadable-ssr-addon')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const webpack = require('webpack')

const SelectedPlugins = []
if (process.env.npm_lifecycle_script.includes('NODE_ANALYZER')) {
  console.log('Setting BundleAnalyzerPlugin Plugin')
  SelectedPlugins.push(new BundleAnalyzerPlugin({
    analyzerMode: 'server',
    generateStatsFile: true,
    statsOptions: { source: false },
    openAnalyzer: true
  }))
} else {
  SelectedPlugins.push(new webpack.optimize.ModuleConcatenationPlugin())
}
module.exports = {
  context: __dirname,

  entry: './front_end/resources/js/App.js',

  output: {
    path: path.resolve('./rafael/server/static/webpack_bundles/'),
    filename: '[name].bundle.js',
    chunkFilename: '[name].chunk.js',
    publicPath: './static/webpack_bundles/'
  },
  optimization: {
    nodeEnv: 'development',
    splitChunks: {
      cacheGroups: {
        commons: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendors',
          chunks: 'all',
          minChunks: 2
        },
        default: {
          minChunks: 2,
          reuseExistingChunk: true
        }
      }
    }
  },
  devtool: 'cheap-module-eval-source-map',
  // SIMPLE DEV SERVER
  devServer: {
    contentBase: path.resolve(__dirname, './dist/'),
    disableHostCheck: true,
    host: '0.0.0.0',
    open: true
  },
  plugins: SelectedPlugins.concat([
    new MiniCssExtractPlugin({
      // Options similar to the same options in webpackOptions.put
      // all options are optional
      filename: '[name].css',
      chunkFilename: '[id].css',
      ignoreOrder: false // Enable to remove warnings about conflicting order
    }),
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, './front_end/templates/index.html'),
      cache: false,
      base: '/',
      favicon: path.resolve(__dirname, './front_end/resources/js/imgs/favicon.ico')
    }),
    new BundleTracker({
      path: './rafael/',
      filename: 'webpack-stats.json'
    }),
    new ReactLoadableSSRAddon({
      filename: 'react-loadable-ssr-addon.json'
    })
  ]),
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
        // query: {
        //   presets: ['react', 'es2015', 'react-hmre'],
        //   plugins: [],
        // },
      },
      {
        test: /\.css$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              // you can specify a publicPath here
              // by default it uses publicPath in webpackOptions.put
              publicPath: '../',
              hmr: process.env.NODE_ENV === 'development'
              // include: '/node_modules[/\\]react-dropdown-tree-select/',
            }
          },
          'css-loader'
        ]
      },
      {
        test: /\.less$/,
        use: [
          {
            loader: 'style-loader'
          },
          {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          },
          {
            loader: 'less-loader',
            options: {
              sourceMap: true
            }
          }
        ]
      },
      {
        test: /\.(jpe?g|gif|png|svg)$/i,
        use: [
          {
            loader: 'url-loader',
            options: {
              limit: 10000
            }
          }
        ]
      },
      {
        test: /favicon\.ico$/,
        loader: 'url',
        query: {
          limit: 1,
          name: '[name].[ext]'
        }
      }
    ]
  },
  resolve: {
    extensions: ['*', '.js', '.jsx']
  }
}

@oneandonlyonebutyou
Copy link
Author

oneandonlyonebutyou commented Feb 28, 2020

@vayser Could you help me, please

@hocineismail
Copy link

hocineismail commented Feb 28, 2020

i have the same problem with create-react-app and i found all class of pagination are null in code source from browser
i try to find and fix this bug from node_modules

@oneandonlyonebutyou
Copy link
Author

oneandonlyonebutyou commented Feb 28, 2020

@hocineismail Actually :) I found that I was using BS4. So I just needed to add

              itemClass="page-item"
              linkClass="page-link"

to my

  <Pagination />

Please try that

@hocineismail
Copy link

yeah thank you so much now the css work

@ahsan-storm
Copy link

ahsan-storm commented May 21, 2020

Please close this issue as @joseph-vedadi's answer solves the issue

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

No branches or pull requests

5 participants