1
votes

I'm using Webpack in my application, in which I create my entry point as index.ts and I'm trying to run it using sass css bootstrap typescript as resources in my project webpack, but I am stuck with these errors,(bootstrap-loader) :

ERROR in ./node_modules/bootstrap-loader/no-op.js (./node_modules/bootstrap-loader/lib/bootstrap.scripts.loader.js?{"bootstrapVersion":3,"useCustomIconFontPath":false,"extractStyles":false,"styleLoaders":["style-loader","css-loader","sass-loader"],"styles":["mixins","normalize","print","glyphicons","s caffolding","type","code","grid","tables","forms","buttons","component-animations","dropdowns","button-groups","input-groups","navs","navbar","breadcrumbs","pagination","pager","labels","badges","jumbotron","thumbnails","alerts","progress-bars","media","list-group","panels","wells","responsive-embed","close","modals","tooltip","popovers","carousel","utilities","responsive-utilities"],"scripts":["transition","alert","button","carousel","collapse","dropdown","modal","tooltip","popover","scrollspy","tab","affix"],"configFilePath":"/projects/bootstrapwebpack/node_modules/bootstrap-loader/.bootstraprc-3-default","bootstrapPath":"/projects/bootstrapwebpack/node_modules/bootstrap-sass","bootstrapRelPath":"../bootstrap-sass"}!./node_modules/bootstrap-loader/no-op.js) ...

In my config.js I have :

const path = require('path');
const webpack = require('webpack');
module.exports = {
entry:  [ 'bootstrap-loader', './src/index.ts',],
module: {
  rules:[
    {
      test: /\.css$/,
       use: [
        'style-loader',
        'css-loader'
            ],
    },
    {
      test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            use: {
            loader: 'babel-loader',
            options: {
              presets: ['env']
              }
            }
      },
      {
        test: /\.(gif|png|jpe?g|svg)$/i,
        use: [
         'file-loader',
          {
            loader: 'image-webpack-loader',
            options: {
            },
          },
        ],
      },
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      },
      {
        test: /\.scss$/,
        use: ['style-loader', 'css-loader', 'sass-loader'],
        exclude: /node_modules/
      },
      // Boooootstrap
      { 
        test: /bootstrap-sass\/assets\/javascripts\//, 
        loader: 'imports-loader?jQuery=jquery' 
      },
      { 
        test: /\.(woff2?|svg)$/, loader: 'url-loader?limit=10000' 
      },
      { 
        test: /\.(ttf|eot)$/, loader: 'file-loader' 
      },
    ],
    }, 
output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
    }
};

Currently I'm trying to use in my package.json these following lines :

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "dev": "webpack --mode development --watch ",
    "build": "webpack --progress -p --watch "
  },
  "dependencies": {
    "autoprefixer": "^9.0.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "bootstrap": "^4.1.2",
    "bootstrap-loader": "^3.0.0",
    "bootstrap-sass": "^3.3.7",
    "css-loader": "^1.0.0",
    "exports-loader": "^0.7.0",
    "file-loader": "^1.1.11",
    "image-webpack-loader": "^4.3.1",
    "jquery": "^3.3.1",
    "mini-css-extract-plugin": "^0.4.1",
    "node-sass": "^4.9.2",
    "popper.js": "^1.14.3",
    "postcss-loader": "^2.1.6",
    "resolve-url-loader": "^2.3.0",
    "sass-loader": "^7.0.3",
    "style-loader": "^0.21.0",
    "ts-loader": "^4.4.2",
    "typescript": "^2.9.2",
    "url-loader": "^1.0.1",
    "webpack": "^4.16.0",
    "webpack-cli": "^3.0.8"
  }
}
1
Why did you put 'bootstrap-loader' before your main entry?yacine benzmane
i tried to put my main entry before 'bootstrap-loader' but nothing happend !!Hafid Bensmail
why do You have postcss-loader in your dependencies ? you never used ityacine benzmane
i have postcss because i was working with sass-loader, but after i changed it and i deleted the sass file and i forgot to remove it from dependencies :) .Hafid Bensmail

1 Answers

1
votes

I had the same problem yesterday. Try adding in ./src/index.ts

   require 'bootstrap/dist/css/bootstrap.min.css';
   require 'bootstrap/dist/js/bootstrap.min.js';