0

下面是我的指令片段,在没有使用 webpack 之前,我使用了 templateUrl 版本,工作正常。我还包括了我的 webpack.config 文件。我似乎无法弄清楚这一点。

function footerContent() {
  'use strict';

  console.log('footerContent');


  return {
    restrict: 'E',
    scope: false,
    template: require('./footer-area.html')
  };
}

// angular
//  .module('alpha')
//  .directive('footerContent', footerContent);

module.exports = function(ngModule) {
  'use strict';

  ngModule.directive('footerContent', footerContent);
};

运行 Webpack 命令会导致此错误,我知道它试图访问错误目录中的文件,但我尝试了 dir 路径的几种变体,但均未成功:

ERROR in . / scripts / Directive / headerContent.js
Module not found: Error: Cannot resolve 'file'
or 'directory'. / header - area.html in / app / scripts / Directive@. / scripts / Directive / headerContent.js 10: 12 - 41

ERROR in . / scripts / Directive / footerContent.js
Module not found: Error: Cannot resolve 'file'
or 'directory'. / footer - area.html in / app / scripts / Directive@. / scripts / Directive / footerContent.js 10: 12 - 41

ERROR in . / scripts / Directive / contentArea.js
Module not found: Error: Cannot resolve 'file'
or 'directory'. / home.html in / app / scripts / Directive@. / scripts / Directive / contentArea.js 10: 12 - 34

ERROR in . / scripts / Directive / socialMediabuttons.js
Module not found: Error: Cannot resolve 'file'
or 'directory'. / social - media - buttons.html in /Users/Tim / Desktop / P / TimothyLombrana / app / scripts / Directive@. / scripts / Directive / socialMediabuttons.js 10: 12 - 50

这是 mywebpack 配置文件:

module.exports = {
  context: __dirname + '/app',
  entry: './index.js',
  output: {
    path: __dirname + '/app',
    filename: 'bundle.js'
  },

  module: {
    loaders: [{
      test: /\.html$/,
      loader: 'raw',
      exclude: /node_modules/
    }]
  }
};
4

0 回答 0