【问题标题】:Webpack - dependency not found (isotope)Webpack - 未找到依赖项(同位素)
【发布时间】:2017-05-03 10:11:37
【问题描述】:

我正在使用 Webpack(laravel 混合版本)并收到 Isotope 错误。谁能看到我做错了什么?

未找到此依赖项:* ./~/isotope-layout/js/layout-modes/masonry.js 中的砌体/砌体

这是我的 webpack 配置,我已经尝试应用同位素站点上显示的“修复”

const webpack = require('webpack')
const path    = require('path')

const config = {
  resolve: {
    alias: {
      'masonry': 'masonry-layout',
      'isotope': 'isotope-layout'
    }
  },
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'vue-waypoint.js',
    library: 'VueWaypoint',
    libraryTarget: 'umd'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        include: path.resolve(__dirname, './src'),
        exclude: /node_modules/,
        use: "babel-loader"
      }
    ]
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin(),
    new webpack.LoaderOptionsPlugin({ minimize: true })
  ]
}

module.exports = config;

【问题讨论】:

    标签: webpack dependencies jquery-isotope laravel-mix


    【解决方案1】:

    这很奇怪,看起来您尝试在代码中重命名 npm 包 masonry-layoutisotope-layout,但别名是关于文件夹和路径 (https://webpack.js.org/configuration/resolve/#resolve-alias)

    您可以简单地使用: require('masonry-layout')import Istotope from 'masonry-layout' npm i masonry-layout --save

    或者您可以将“masonry-layout”作为全局包传递:

    new webpack.ProvidePlugin({masonry: 'masonry-layout'})

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-28
      • 2018-07-26
      • 1970-01-01
      • 2021-03-17
      • 2019-02-24
      • 2021-06-16
      • 2017-09-18
      • 2013-08-26
      相关资源
      最近更新 更多