Webpack - 未找到依赖关系(同位素)

时间:2017-05-03 10:11:38

标签: webpack dependencies isotope laravel-mix

我正在使用Webpack(laravel mix版本)并且使用Isotope会出错。谁能看到我做错了什么?

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

中的砌体/砌体

这是我的webpack confix,我试图应用同位素网站上显示的'修复'

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;

1 个答案:

答案 0 :(得分:0)

这很奇怪,看起来你试图在你的代码中重命名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

或者你可以通过'砌筑布局'作为全球一揽子计划:

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