W
W
Wasya UK2018-03-29 21:37:40
npm
Wasya UK, 2018-03-29 21:37:40

How to include bower in webpack?

I include the library in main.js, but nothing works. I get ERROR in ./app/public/javascripts/main.js
Module not found:

Here is the webpack.config:

const HtmlWebPackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: './app/public/javascripts/main.js',
  output: {
    filename: './bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: ["bower_components", "node_modules"],
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader",
            options: { minimize: true }
          }
        ]
      }
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./app/public/index.html",
      filename: "./index.html",
      inject: true
    })
  ]
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wasya UK, 2018-03-29
@dmc1989

const HtmlWebPackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: './app/public/javascripts/main.js',
  output: {
    filename: './bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /\.node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader",
            options: { minimize: true }
          }
        ]
      }
    ]
  },
  node: {
    fs: "empty"
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./app/public/index.html",
      filename: "./index.html",
      inject: true
    })
  ]
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question