S
S
Sergey Gromov2017-01-23 14:07:16
JavaScript
Sergey Gromov, 2017-01-23 14:07:16

Webpack how to specify module paths?

Good afternoon, help, webpack stopped finding paths to the node_modules folder
Here is my assembly https://github.com/reskwer/blank
npm run gulp - The project is launched like this (I do not have Gulp4 globally)
gulp is in dev/gulp/
Webpack task

import gulp from 'gulp';
import webpack from 'webpack-stream';
import plumber from 'gulp-plumber';
import errorHandler from './errorHandler';
import {projectPath, distPath} from './path';

gulp.task('js', function() {
  let webpackOptions = {
    output: {
      filename: distPath('js/script.js'),
      library: 'app'
    },
    devtool: 'cheap-inline-module-source-map',
    module: {
      loaders: [{
        test: /\.js$/,
        loader: 'babel-loader'
      }]
    }
  }

  return gulp.src(projectPath('js/app.js'))
  .pipe(plumber({
    errorHandler: errorHandler
  }))
  .pipe(webpack(webpackOptions))
  .pipe(gulp.dest(distPath('js')))
});

In app.js, I unload jQuery and the local module, the jiquery is not unloaded, and the local one is fine in the assembly
import word from './home';
import $ from 'jquery';

Please help me solve the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Storozhenko, 2017-01-23
@montecazazza

I don't use Galp, I say right away...
Paths to modules are specified in the resolve section. You can specify aliases and any other.

//...
resolve: {
  modules: [/*путь_к_папке_с_сорсом,*/ "node_modules"]
}
//...

It is very strange that it does not see, by default all imports should come from node_modules as far as I know
https://webpack.js.org/configuration/resolve/#reso...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question