gulp-webpack错误:找不到输入模块:错误:无法解析模块

时间:2019-03-06 07:12:55

标签: javascript json wordpress webpack gulp-watch

当我尝试gulp scipts时,会引发以下错误

在输入模块中找不到错误:

  

错误:无法解析'C:/ Users / milan / Local   网站/project-university/app/public/wp-content/themes/fictional-university-theme/js/scripts.js'   在“ C:\ Users \ milan \ Local Sites \ project-university \ app \ public”

下面是我的 webpack.config.js

const path = require('path'),
settings = require('./settings');

module.exports = {
  entry: {
    App:   settings.themeLocation + "js/scripts.js"
  },
  output: {
    path: path.resolve(__dirname, settings.themeLocation + "js"),
    filename: "scripts-bundled.js"
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  },
  mode: 'development'
}

和我的 settings.js

exports.urlToPreview = 'http://project-university.local/';


exports.themeLocation = 

'C:/Users/milan/Local Sites/project-university/app/public/wp-content/themes/fictional-university-theme/';

下面是我的文件目录,

Project ---- app ------ public ----------(wordpress内容文件)

1 个答案:

答案 0 :(得分:0)

问题是在settings.js中定义的编译路径。将定义的路径更改为

exports.themeLocation = './public/wp-content/themes/fictional-university-theme/';

exports.themeLocation = './wp-content/themes/fictional-university-theme/';