"use strict";

var _path = _interopRequireDefault(require("path"));

var _utils = require("../utils");

var _loaderUtils = require("../loaderUtils");

var _getLibraryImactPlugins = _interopRequireDefault(require("../pluginUtils/getLibraryImactPlugins"));

var _configsAssetsLoaders = require("../loaderUtils/configsAssetsLoaders");

var _resolvers = require("./resolvers");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const options = (0, _utils.getOptions)();
const {
  docs: {
    componentFolder,
    cssUniqueness,
    customClassNamePrefix,
    plugins,
    exclude,
    patterns,
    mediaQueryHoverActiveString,
    cssVariableReplacementConfig,
    selectorWeightConfig,
    prefixConfig,
    cssHashSelectors,
    enableChunkHash,
    classNamePrefix,
    postCssPluginOrder,
    externals
  },
  app: {
    folder
  }
} = options;
const appPath = process.cwd();
const nameTemplate = (0, _configsAssetsLoaders.createNameTemplate)(enableChunkHash);
module.exports = {
  entry: {
    main: [_path.default.resolve(__dirname, '..', 'hooks', 'docsProptypeHook.js'), _path.default.join(appPath, componentFolder, 'index.js')],
    vendor: ['react', 'react-dom', 'redux', 'react-redux']
  },
  devtool: 'none',
  mode: 'development',
  stats: 'errors-only',
  output: {
    path: _path.default.join(appPath, 'build'),
    filename: 'js/[name].js',
    publicPath: '/docs/',
    library: 'Component',
    libraryTarget: 'umd'
  },
  plugins: (0, _getLibraryImactPlugins.default)(options),
  module: {
    rules: [{
      test: /\.js$/,
      use: [{
        loader: 'babel-loader',
        options: {
          presets: [[require.resolve('@babel/preset-env'), {
            modules: false
          }], require.resolve('@babel/preset-react')],
          plugins: [[require.resolve('@babel/plugin-transform-runtime'), {
            helpers: true,
            regenerator: false
          }], require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('@babel/plugin-syntax-object-rest-spread')],
          cacheDirectory: true
        }
      }],
      include: _path.default.join(appPath, folder)
    }, {
      test: /\.docs\.js$/,
      use: require.resolve('../loaders/docsLoader.js'),
      include: _path.default.join(appPath, folder),
      exclude: /node_modules/
    }, {
      test: /(\.module)?\.css$/,
      use: (0, _loaderUtils.getCSSLoaders)({
        plugins,
        exclude,
        patterns,
        mediaQueryHoverActiveString,
        cssVariableReplacementConfig,
        selectorWeightConfig,
        prefixConfig,
        classNameBlob: false,
        cssUniqueness,
        customClassNamePrefix,
        selectorReplace: null,
        cssHashSelectors,
        classNamePrefix,
        postCssPluginOrder
      })
    }, (0, _configsAssetsLoaders.configImageLoader)(nameTemplate), (0, _configsAssetsLoaders.configFontLoader)(nameTemplate), (0, _configsAssetsLoaders.configSVGLoader)(nameTemplate), (0, _configsAssetsLoaders.configAudioLoader)(nameTemplate), (0, _configsAssetsLoaders.configVideoLoader)(nameTemplate), {
      test: /\.html$/,
      use: {
        loader: 'html-loader',
        options: {
          attrs: [':data-src'],
          interpolate: 'require'
        }
      }
    }, {
      test: /\.tmpl$/,
      use: [{
        loader: 'html-loader',
        options: {
          interpolate: 'require',
          ignoreCustomFragments: [/\{\{.*?}}/, /\$\{.*?}/],
          minimize: true,
          removeComments: true,
          collapseWhitespace: false,
          removeAttributeQuotes: false,
          minifyCSS: false,
          minifyJS: false
        }
      }]
    }]
  },
  externals: Object.assign({
    ZC: '$ZC'
  }, externals),
  resolve: (0, _resolvers.moduleResolver)(options),
  resolveLoader: (0, _resolvers.loaderResolver)(options)
};