简体   繁体   English

使用webpack导入print.js

[英]Importing print.js using webpack

I am trying to import the print.js library into the vendor bundle in my project using webpack. 我正在尝试使用webpack将print.js库导入项目中的供应商捆绑包中。 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. print.js node_modules文件夹包含一些有趣的文件webpack.mix.js ,而src/index.js似乎是用ES6编写的。 Maybe I am missing a dependency or ES6 support? 也许我缺少依赖项或ES6支持?

my webpack.config.js : 我的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. 该库在npm中重命名为print-js

Try: 尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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