Webpack with Phantom / Casper / Spooky:无法打开文件

时间:2017-02-10 05:41:51

标签: javascript webpack casperjs webpack-2 spookyjs

My Spooky / Casper / Phantom项目工作正常。然后我试图让Webpack参与进来。

当我运行程序时,我得到:

CasperError: Can't find module node_modules/spooky/lib/bootstrap/emit
[ { file: 'phantomjs://code/bootstrap.js',
    line: 297,
    function: 'patchedRequire' } ]

我的文件结构如下:

  • DIST /
  • index.js
  • webpack.config.js
  • ...
  • node_modules /

在我的index.js

import Spooky from 'spooky';

const spooky = new Spooky({
  child: {
    transport: 'http',
    spooky_lib: 'node_modules/spooky/',
  },
  casper: {
    logLevel: 'debug',
    verbose: false
  }
}, ...);

我的webpack.config.js

const path = require('path');

module.exports = {
  context: __dirname,
  entry: './index.js',
  target: 'node',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'index.js',
    publicPath: path.join(__dirname, 'dist')
  },
  devtool: 'source-maps',
  node: {
    __dirname: true
  },
  module: {
    rules: [
      {
        test: /\.(js)$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
        },
      }
    ]
  },
  resolve: {
    extensions: ['.js']
  }
};

0 个答案:

没有答案