javascript - 使用 webpack 导入 print.js

标签 javascript webpack printjs

我正在尝试导入 print.js使用 webpack 将库添加到我的项目中的 vendor 包中。由于某种原因它无法解析该模块。 print.js node_modules 文件夹包含一些有趣的文件 - webpack.mix.jssrc/index.js 似乎是用 ES6 编写的。也许我缺少依赖项或 ES6 支持?

我的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)
    })
  ]
};

错误:

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

最佳答案

该库在 npm 中重命名为 print-js

尝试:

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

关于javascript - 使用 webpack 导入 print.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44977270/

相关文章:

javascript - 计算两个移动元素之间的距离

javascript - ReactJS:如何使用 localStorage 更新属性状态?

node.js - Webpack 配置不起作用,路径必须是绝对路径

javascript - 内联 javascript onclick 事件

javascript - 在 flatMapLatest 中重新使用订阅

webpack - 使用 webpack 时出现 Bootstrap popper 问题

webpack - 在webpack文件顶部包含注释

javascript - 使用 printjs 的语义 ui 模态打印没有得到结果

javascript - 无论如何要等待打印窗口在 print.js 中关闭