简体   繁体   中英

Importing print.js using webpack

I am trying to import the print.js library into the vendor bundle in my project using webpack. For some reason it cannot resolve the module. The print.js node_modules folder contains some interesting files - webpack.mix.js and the src/index.js appears to be written in ES6. Maybe I am missing a dependency or ES6 support?

my webpack.config.js :

var webpack = require("webpack"),
    path = require("path");

const Dotenv = require('dotenv-webpack');

module.exports = {

 context: __dirname + "/public",
  entry: {
    app: "./application.js",
    vendor: ["angular", "angular-route", "scrollreveal", "clipboard", "print.js"]  
  },
  output: {
    path: __dirname + "/public/scripts",
    filename: "trails.bundle.js"
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({name: "vendor", filename: "vendor.bundle.js"}),
    new Dotenv({
      path: './.env', // Path to .env file (this is the default)
    })
  ]
};

The error:

ERROR in multi angular angular-route scrollreveal clipboard print.js
Module not found: Error: Can't resolve 'print.js'

The library was renamed to print-js in npm.

Try:

...
entry: {
  app: "./application.js",
  vendor: ["angular", "angular-route", "scrollreveal", "clipboard", "print-js"]  
},
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM