urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

Fix webpack loading #253

Closed prestonvanloon closed 8 years ago

prestonvanloon commented 8 years ago

206 wasn't working for me. Closes #108

I'm not sure if this breaks other loaders, but it works for webpack.

Here's my webpack config, if that helps anyone.

const path = require('path');
const appPath = path.join(__dirname, 'app');
const wwwPath = path.join(__dirname, 'www');
const pkg = require('./package.json');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const BowerWebpackPlugin = require('bower-webpack-plugin');

module.exports = {
  entry: path.join(appPath, 'index.js'),
  output: {
    path: wwwPath,
    filename: 'script-[hash:6].js'
  },
  module: {
    loaders: [{
      test: /\.html$/,
      loader: 'html'
    }, {
      test: /\.json$/,
      loader: 'json'
    }, {
      test: /\.(png|jpg)$/,
      loader: 'file?name=img/[name].[ext]'
    }, {
      test: /\.css$/,
      loader: 'style!css'
    }, {
      test: /\.jsx?$/,
      exclude: /(node_modules|bower_components)/,
      loader: 'ng-annotate!babel?presets[]=es2015'
    }, {
      test: /\.scss$/,
      loader: 'style!css!sass!'
    }, {
      test: [/ionicons\.svg/, /ionicons\.eot/, /ionicons\.ttf/, /ionicons\.woff/],
      loader: 'file?name=fonts/[name].[ext]'
    }]
  },
  resolve: {
    extensions: ['', '.js', '.json', '.scss', '.html'],
    root: [
      appPath,
      path.join(__dirname, 'node_modules'),
      path.join(__dirname, 'bower_components')
    ],
    moduleDirectories: [
      'node_modules',
      'bower_components'
    ]
  },
  plugins: [
    new BowerWebpackPlugin(),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      pkg: pkg,
      template: path.join(appPath, 'index.ejs'),
      inject: 'body'
    })
  ]
};

The previous issue was the "angular.module is not a function", https://github.com/urish/angular-moment/issues/108#issuecomment-144480550

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-1.2%) to 91.518% when pulling f8bed205ee283f118e3806ee7fb42729def7561c on prestonvanloon:master into 7798910c528d910fc431705c88919355de066300 on urish:master.

urish commented 8 years ago

Thanks for your time. I'm not going to merge this, is it is likely to break for other use-cases. However, it could be partially fixed by commit 517f42f