Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Waypoint npm - Error: Can't resolve 'waypoint

I have a vue project and installed waypoints

npm install waypoints

I try to import it

import waypoint from 'waypoints';

but get an error

Error: Can't resolve 'waypoints' in /Mypath

What am I doing wrong?

var webpack = require('webpack');
var path = require('path');
let ExtractTextPlugin = require("extract-text-webpack-plugin");
var WebpackNotifierPlugin = require('webpack-notifier');
var fs = require('file-system');
var CleanWebpackPlugin = require('clean-webpack-plugin');


module.exports = {
/*node: {
  fs: "empty"
},*/
    resolve: {
    alias: {
      'masonry': 'masonry-layout',
      'isotope': 'isotope-layout'
    }
  },

    entry: './main.js',
    devtool: 'source-map',
    output: {
        path: path.resolve(__dirname, './public/assets'),
        filename: 'bundle.[chunkhash].js',
    },

    module: {
        rules: [

         {  test: /\.js$/, 
                exclude: /node_modules/, 
                loader: "babel-loader?presets[]=es2015",

             },

            {
                test:/\.scss$/,
                use: ExtractTextPlugin.extract({
                    use: [{loader:'css-loader?sourceMap'}, {loader:'sass-loader', options: {
                    sourceMap: true,

                }}],

                })
            },   



            {
                 test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
          }
          // other vue-loader options go here
        }
      },



        ]
    },  

    plugins: [
new CleanWebpackPlugin(['assets/*', 'css/*'], {
            root: '/Users/LEITH/sites/laravelleith/public',
            verbose: true,
            dry: false,
            exclude: ['360lockturret.jpg'],
            watch: true
    }),

        new webpack.optimize.UglifyJsPlugin(),
        new ExtractTextPlugin('app.[chunkhash].css'),
        new WebpackNotifierPlugin(),

        function() {
            this.plugin('done', stats =>{
                fs.writeFileSync(
                    path.join(__dirname, 'manifest.json'),
                    JSON.stringify(stats.toJson().assetsByChunkName)
                )

            });
        }

    ]

};
like image 794
LeBlaireau Avatar asked Apr 07 '17 16:04

LeBlaireau


1 Answers

Waypoints comes bundled in several flavours, even via NPM, but I couldn't work out if there's a default implementation or not. So that's why your typical import Waypoint from 'waypoints' directive doesn't work.

I resolved this for my "vanilla ES6 + Webpack" setup as follows:

import 'waypoints/lib/noframework.waypoints.min.js';

const waypoint = new Waypoint({
  element: document.getElementById('myScrollTarget'),
  handler: () => {}
});
like image 80
markedup Avatar answered Oct 22 '22 01:10

markedup