const I18nPlugin = require('../ui-build/webpack/i18nPlugin')
const path = require('path')
const baseWebpackConfig = require('../ui-build/webpack')

const root = path.resolve(__dirname, '..')

module.exports = {
  stories: [
    '../ui/**/*.stories.mdx',
    '../ui/**/*.stories.@(js|jsx|ts|tsx)'
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials'
  ],
  webpackFinal: async (config) => {
    config.module.noParse = [/i18nliner\/dist\/lib\/i18nliner/]
    config.plugins.push(new I18nPlugin())
    config.resolveLoader.modules = [
      path.resolve(__dirname, '../ui-build/webpack'),
      'node_modules'
    ]

    config.resolve.modules = [
      path.resolve(__dirname, '../ui/shims'),
      path.resolve(__dirname, '../public/javascripts'), // for translations
      'node_modules'
    ]
    config.resolve.alias = {...baseWebpackConfig.resolve.alias, ...config.resolve.alias}
    config.module.rules = [
      ...config.module.rules,
      {
        test: /\.coffee$/,
        include: [path.resolve(__dirname, '../ui')],
        loaders: ['coffee-loader']
      },
      {
        test: /\.handlebars$/,
        include: [path.resolve(__dirname, '../ui')],
        loaders: ['i18nLinerHandlebars']
      }
    ]

    return config
  }
}

const I18nPlugin = require('../ui-build/webpack/i18nPlugin')
const path = require('path')
const baseWebpackConfig = require('../ui-build/webpack')

const root = path.resolve(__dirname, '..')

module.exports = {
  stories: [
    '../ui/**/*.stories.mdx',
    '../ui/**/*.stories.@(js|jsx|ts|tsx)'
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials'
  ],
  webpackFinal: async (config) => {
    config.module.noParse = [/i18nliner\/dist\/lib\/i18nliner/]
    config.plugins.push(I18nPlugin)
    config.resolveLoader.modules = [
      path.resolve(__dirname, '../ui-build/webpack'),
      'node_modules'
    ]

    config.resolve.modules = [
      path.resolve(__dirname, '../ui/shims'),
      path.resolve(__dirname, '../public/javascripts'), // for translations
      'node_modules'
    ]
    config.resolve.alias = {...baseWebpackConfig.resolve.alias, ...config.resolve.alias}
    config.module.rules = [
      ...config.module.rules,
      {
        test: /\.coffee$/,
        include: [path.resolve(__dirname, '../ui')],
        loaders: ['coffee-loader']
      },
      {
        test: /\.handlebars$/,
        include: [path.resolve(__dirname, '../ui')],
        loaders: ['i18nLinerHandlebars']
      }
    ]

    return config
  }
}

Fix i18nPlugin issue introduced with g/277926
Fix i18nPlugin issue introduced with g/277926

Test Plan
1. Pull down code
2. `yarn storybook` should open storybook
3. Should not throw an error for storybook regarding i18nPlugin

Change-Id: I2fc15dfae332819d8e45993314f4d0529427520c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278846
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Reviewed-by: Charley Kline <05950d7e90ba5e3da323378368c22b3ffaaf6647@instructure.com>
Product-Review: Charley Kline <05950d7e90ba5e3da323378368c22b3ffaaf6647@instructure.com>
QA-Review: Chawn Neal <908eabd8c84ff6c7c139535b8d37802d58ad1683@instructure.com>
