<commit_before>const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const WebpackMd5Hash = require('webpack-md5-hash');

//=========================================================
//  ENVIRONMENT VARS
//---------------------------------------------------------
const NODE_ENV = process.env.NODE_ENV;

const ENV_DEVELOPMENT = NODE_ENV === 'development';
const ENV_PRODUCTION = NODE_ENV === 'production';
const ENV_TEST = NODE_ENV === 'test';

const HOST = process.env.HOST || 'localhost';
const PORT = process.env.PORT || 3000;

//=========================================================
//  CONFIG
//---------------------------------------------------------
const config = {};
module.exports = config;

config.resolve = {
  extensions: ['', '.ts', '.js'],
  modulesDirectories: ['node_modules'],
  root: path.resolve('.')
};

config.module = {
  loaders: [
    {test: /\.html$/, loader: 'raw'},
    {test: /\.ts$/, loader: 'ts', exclude: /node_modules/},
    {test: /\.scss$/, loader: 'raw!postcss!sass', exclude: path.resolve('src/views/common/styles'), include: path.resolve('src/views')}
  ]
};

config.plugins = [
  new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
  })
];

config.postcss = [
  autoprefixer({ browsers: ['last 3 versions'] })
];

config.sassLoader = {
  outputStyle: 'compressed',
  precision: 10,
  sourceComments: false
};

//=====================================
//  DEVELOPMENT or PRODUCTION
//-------------------------------------
if (ENV_DEVELOPMENT || ENV_PRODUCTION) {
  config.entry = {
    main: ['./src/main.ts'],
    polyfills: './src/polyfills.ts',
    vendor: './src/vendor.ts'
  };

  config.output = {
    filename: '[name].js',
    path: path.resolve('./target'),
    publicPath: '/'
  };

  config.plugins.push(
    new webpack.optimize.CommonsChunkPlugin({
      name: ['vendor', 'polyfills'],
      minChunks: Infinity
    }),
    new HtmlWebpackPlugin({
      chunkSortMode: 'dependency',
      filename: 'index.html',
      hash: false,
      inject: 'body',
      template: './src/index.html'
    })
  );
}

//=====================================
//  DEVELOPMENT
//-------------------------------------
if (ENV_DEVELOPMENT) {
  config.devtool = 'cheap-module-source-map';

  config.entry.main.unshift(`webpack-dev-server/client?http://${HOST}:${PORT}`);

  config.module.loaders.push(
    {test: /\.scss$/, loader: 'style!css!postcss!sass', include: path.resolve('src/views/common/styles')}
  );

  config.devServer = {
    contentBase: './src',
    historyApiFallback: true,
    host: HOST,
    port: PORT,
    publicPath: config.output.publicPath,
    stats: {
      cached: true,
      cachedAssets: true,
      chunks: true,
      chunkModules: false,
      colors: true,
      hash: false,
      reasons: true,
      timings: true,
      version: false
    }
  };
}

//=====================================
//  PRODUCTION
//-------------------------------------
if (ENV_PRODUCTION) {
  config.devtool = 'source-map';

  config.output.filename = '[name].[chunkhash].js';

  config.module.loaders.push(
    {test: /\.scss$/, loader: ExtractTextPlugin.extract('css?-autoprefixer!postcss!sass'), include: path.resolve('src/views/common/styles')}
  );

  config.plugins.push(
    new WebpackMd5Hash(),
    new ExtractTextPlugin('styles.[contenthash].css'),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      mangle: true,
      compress: {
        dead_code: true, // eslint-disable-line camelcase
        screw_ie8: true, // eslint-disable-line camelcase
        unused: true,
        warnings: false
      }
    })
  );
}

//=====================================
//  TEST
//-------------------------------------
if (ENV_TEST) {
  config.devtool = 'inline-source-map';

  config.module.loaders.push(
    {test: /\.scss$/, loader: 'style!css!postcss!sass', include: path.resolve('src/views/common/styles')}
  );
}
<commit_msg>chore(webpack): clean up config<commit_after>const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const WebpackMd5Hash = require('webpack-md5-hash');

//=========================================================
//  ENVIRONMENT VARS
//---------------------------------------------------------
const NODE_ENV = process.env.NODE_ENV;

const ENV_DEVELOPMENT = NODE_ENV === 'development';
const ENV_PRODUCTION = NODE_ENV === 'production';
const ENV_TEST = NODE_ENV === 'test';

const HOST = process.env.HOST || 'localhost';
const PORT = process.env.PORT || 3000;

//=========================================================
//  LOADERS
//---------------------------------------------------------
const loaders = {
  componentStyles: {
    test: /\.scss$/,
    loader: 'raw!postcss!sass',
    exclude: path.resolve('src/views/common')
  },
  sharedStyles: {
    test: /\.scss$/,
    loader: 'style!css!postcss!sass',
    include: path.resolve('src/views/common')
  },
  html: {
    test: /\.html$/,
    loader: 'raw'
  },
  typescript: {
    test: /\.ts$/,
    loader: 'ts',
    exclude: /node_modules/
  }
};

//=========================================================
//  CONFIG
//---------------------------------------------------------
const config = module.exports = {};

config.resolve = {
  extensions: ['', '.ts', '.js'],
  modulesDirectories: ['node_modules'],
  root: path.resolve('.')
};

config.module = {
  loaders: [
    loaders.typescript,
    loaders.componentStyles,
    loaders.html
  ]
};

config.plugins = [
  new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
  })
];

config.postcss = [
  autoprefixer({browsers: ['last 3 versions']})
];

config.sassLoader = {
  outputStyle: 'compressed',
  precision: 10,
  sourceComments: false
};

//=====================================
//  DEVELOPMENT or PRODUCTION
//-------------------------------------
if (ENV_DEVELOPMENT || ENV_PRODUCTION) {
  config.entry = {
    main: ['./src/main.ts'],
    polyfills: './src/polyfills.ts',
    vendor: './src/vendor.ts'
  };

  config.output = {
    filename: '[name].js',
    path: path.resolve('./target'),
    publicPath: '/'
  };

  config.plugins.push(
    new webpack.optimize.CommonsChunkPlugin({
      name: ['vendor', 'polyfills'],
      minChunks: Infinity
    }),
    new HtmlWebpackPlugin({
      chunkSortMode: 'dependency',
      filename: 'index.html',
      hash: false,
      inject: 'body',
      template: './src/index.html'
    })
  );
}

//=====================================
//  DEVELOPMENT
//-------------------------------------
if (ENV_DEVELOPMENT) {
  config.devtool = 'cheap-module-source-map';

  config.entry.main.unshift(`webpack-dev-server/client?http://${HOST}:${PORT}`);

  config.module.loaders.push(loaders.sharedStyles);

  config.devServer = {
    contentBase: './src',
    historyApiFallback: true,
    host: HOST,
    port: PORT,
    stats: {
      cached: true,
      cachedAssets: true,
      chunks: true,
      chunkModules: false,
      colors: true,
      hash: false,
      reasons: true,
      timings: true,
      version: false
    }
  };
}

//=====================================
//  PRODUCTION
//-------------------------------------
if (ENV_PRODUCTION) {
  config.devtool = 'source-map';

  config.output.filename = '[name].[chunkhash].js';

  config.module.loaders.push({
    test: /\.scss$/,
    loader: ExtractTextPlugin.extract('css?-autoprefixer!postcss!sass'),
    include: path.resolve('src/views/common')
  });

  config.plugins.push(
    new WebpackMd5Hash(),
    new ExtractTextPlugin('styles.[contenthash].css'),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      mangle: true,
      compress: {
        dead_code: true, // eslint-disable-line camelcase
        screw_ie8: true, // eslint-disable-line camelcase
        unused: true,
        warnings: false
      }
    })
  );
}

//=====================================
//  TEST
//-------------------------------------
if (ENV_TEST) {
  config.devtool = 'inline-source-map';

  config.module.loaders.push(loaders.sharedStyles);
}
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const BabiliPlugin = require('babili-webpack-plugin');
const pkg = require('./package.json');

let banner =
  `OBS WebSocket Javascript API (${pkg.name}) v${pkg.version}\n` +
  `Author: ${pkg.author}\n` +
  `License: ${pkg.license}\n` +
  `Repository: ${pkg.repoUrl}\n` +
  `Build Timestamp: ${pkg.timestamp || new Date().toISOString()}`;

banner += pkg.sha ? `\nBuilt from Commit: ${pkg.repoUrl}/commit/${pkg.sha}` : ``;

module.exports = {
  target: 'web',
  entry: {
    'obs-websocket': './index.js',
    'obs-websocket.min': './index.js'
  },
  output: {
    path: path.join(__dirname, '/dist'),
    filename: '[name].js',
    library: 'OBSWebSocket'
  },
  externals: {
    ws: 'WebSocket'
  },
  devtool: 'source-map',
  plugins: [
    new BabiliPlugin({}, {
      test: /\.min\.js($|\?)/i
    }),
    new webpack.BannerPlugin({banner})
  ]
};
<commit_msg>ci: Remove comments from Babili Webpack Plugin<commit_after>const path = require('path');
const webpack = require('webpack');
const BabiliPlugin = require('babili-webpack-plugin');
const pkg = require('./package.json');

let banner =
  `OBS WebSocket Javascript API (${pkg.name}) v${pkg.version}\n` +
  `Author: ${pkg.author}\n` +
  `License: ${pkg.license}\n` +
  `Repository: ${pkg.repoUrl}\n` +
  `Build Timestamp: ${pkg.timestamp || new Date().toISOString()}`;

banner += pkg.sha ? `\nBuilt from Commit: ${pkg.repoUrl}/commit/${pkg.sha}` : ``;

module.exports = {
  target: 'web',
  entry: {
    'obs-websocket': './index.js',
    'obs-websocket.min': './index.js'
  },
  output: {
    path: path.join(__dirname, '/dist'),
    filename: '[name].js',
    library: 'OBSWebSocket'
  },
  externals: {
    ws: 'WebSocket'
  },
  devtool: 'source-map',
  plugins: [
    new BabiliPlugin({}, {
      test: /\.min\.js($|\?)/i,
      comments: false
    }),
    new webpack.BannerPlugin({banner})
  ]
};
<|endoftext|>


<commit_before>// webpack.config.js

var nodeExternals = require('webpack-node-externals')
var path = require('path')
var webpack = require('webpack')

var config = {
  entry: ['whatwg-fetch', path.join(__dirname, 'src', 'index.js')],
  devtool: 'source-map',
  target: 'node',
  output: {
    path: path.join(__dirname, '/dist'),
    filename: 'cozy-api.js',
    library: 'cozy-api',
    libraryTarget: 'umd',
    umdNamedDefine: true
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /(node_modules|bower_components)/
      },
      {
        test: /\.js$/,
        loader: 'standard-loader',
        exclude: /node_modules|.tmp\/mocha-webpack/
      }
    ]
  },
  resolve: {
    root: path.resolve('./src'),
    extensions: ['', '.js']
  }
}

if (process.env.NODE_ENV === 'test') {
  config.externals = [nodeExternals()]
  config.plugins = [
    new webpack.ProvidePlugin({ 'btoa': 'btoa' }),
    new webpack.EnvironmentPlugin(Object.keys(process.env))
  ]
}

module.exports = config
<commit_msg>add regenerator-runtime to bundle<commit_after>// webpack.config.js

var nodeExternals = require('webpack-node-externals')
var path = require('path')
var webpack = require('webpack')

var config = {
  entry: ['whatwg-fetch', 'regenerator-runtime/runtime', path.join(__dirname, 'src', 'index.js')],
  devtool: 'source-map',
  target: 'node',
  output: {
    path: path.join(__dirname, '/dist'),
    filename: 'cozy-api.js',
    library: 'cozy-api',
    libraryTarget: 'umd',
    umdNamedDefine: true
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /(node_modules|bower_components)/
      },
      {
        test: /\.js$/,
        loader: 'standard-loader',
        exclude: /node_modules|.tmp\/mocha-webpack/
      }
    ]
  },
  resolve: {
    root: path.resolve('./src'),
    extensions: ['', '.js']
  }
}

if (process.env.NODE_ENV === 'test') {
  config.externals = [nodeExternals()]
  config.plugins = [
    new webpack.ProvidePlugin({ 'btoa': 'btoa' }),
    new webpack.EnvironmentPlugin(Object.keys(process.env))
  ]
}

module.exports = config
<|endoftext|>


<commit_before>require('dotenv').config()
const path = require('path')
const webpack = require('webpack')

const { VueLoaderPlugin } = require('vue-loader')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin')
const WebpackNotifierPlugin = require('webpack-notifier')
const ManifestPlugin = require('webpack-manifest-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

const hmr = process.argv.includes('--hot')
const production = process.env.NODE_ENV === 'production'
const devServerPort = parseInt(process.env.DEV_SERVER_PORT || '8080', 10)
const devServerUrl = process.env.DEV_SERVER_URL || 'http://localhost:8080'

const publicPathFolder = production ? '/dist/' : '/build/'
const publicPath = hmr ? `${devServerUrl}${publicPathFolder}` : publicPathFolder

function getEntryConfig (name, analyzerPort, alias = {}) {
  let plugins = [
    new VueLoaderPlugin(),
    new webpack.IgnorePlugin(/jsdom$/),
    new FriendlyErrorsWebpackPlugin(),
    new WebpackNotifierPlugin(),
    new MiniCssExtractPlugin({
      filename: production ? 'css/[name].[chunkhash].css' : 'css/[name].css'
    }),
    new ManifestPlugin({
      fileName: `manifest-${name}.json`,
      publicPath,
      writeToFileEmit: true
    })
  ]

  if (production) {
    plugins.push(...[
      new BundleAnalyzerPlugin({
        analyzerPort
      })
    ])
  }

  let postcssPlugins = [
    require('autoprefixer')()
  ]

  if (production) {
    postcssPlugins.push(require('cssnano')())
  }

  let cssLoaders = [
    hmr ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
    {
      loader: 'css-loader',
      options: {
        sourceMap: true
      }
    }, {
      loader: 'postcss-loader',
      options: {
        ident: 'postcss',
        sourceMap: true,
        plugins: postcssPlugins
      }
    }
  ]

  return {
    entry: {
      [name]: [
        `./resources/js/${name}/app.js`,
        `./resources/sass/${name}/app.scss`
      ]
    },
    output: {
      path: path.resolve(__dirname, 'public' + publicPathFolder),
      filename: production ? 'js/[name].[chunkhash].js' : 'js/[name].js',
      publicPath
    },
    module: {
      rules: [
        {
          test: /\.css$/,
          use: cssLoaders
        },
        {
          test: /\.scss$/,
          use: cssLoaders.concat([
            {
              loader: 'resolve-url-loader'
            }, {
              loader: 'sass-loader',
              options: {
                outputStyle: 'expanded',
                sourceMap: true
              }
            }
          ])
        },
        {
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          enforce: 'pre'
        },
        {
          test: /\.vue$/,
          loader: 'vue-loader'
        },
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        },
        {
          test: /\.(png|jpe?g|gif)$/,
          use: [
            {
              loader: 'url-loader',
              options: {
                name: (path) => {
                  if (!/node_modules/.test(path)) {
                    return 'images/[name].[ext]?[hash]'
                  }

                  return `images/vendor-${name}/` + path
                    .replace(/\\/g, '/')
                    .replace(
                      /((.*(node_modules))|images|image|img|assets)\//g, ''
                    ) + '?[hash]'
                },
                limit: 4096
              }
            }
          ]
        },
        {
          test: /\.(woff2?|ttf|eot|svg|otf)$/,
          loader: 'url-loader',
          options: {
            name: (path) => {
              if (!/node_modules/.test(path)) {
                return 'fonts/[name].[ext]?[hash]'
              }

              return `fonts/vendor-${name}/[name].[ext]?[hash]`
            },
            limit: 4096
          }
        }
      ]
    },
    optimization: {
      splitChunks: {
        cacheGroups: {
          vendor: {
            test: /node_modules.*\.js$/,
            name: `vendor-${name}`,
            chunks: 'all'
          }
        }
      }
    },
    plugins,
    resolve: {
      extensions: ['.js', '.vue', '.json'],
      alias: Object.assign({
        'sweetalert2$': 'sweetalert2/dist/sweetalert2.js'
      }, alias)
    },
    externals: {
      jquery: 'jQuery',
      'popper.js': 'Popper'
    },
    devtool: production ? 'source-map' : 'cheap-module-eval-source-map',
    devServer: {
      contentBase: path.resolve(__dirname, 'public'),
      headers: {
        'Access-Control-Allow-Origin': '*'
      },
      historyApiFallback: true,
      compress: true,
      noInfo: true,
      quiet: true,
      host: '0.0.0.0',
      port: devServerPort
    }
  }
}

module.exports = [
  getEntryConfig('frontend', 8888, {
    'vue$': 'vue/dist/vue.esm.js'
  }),
  getEntryConfig('backend', 8889)
]
<commit_msg>Excludes node_modules from watchig, to speed up file sync<commit_after>require('dotenv').config()
const path = require('path')
const webpack = require('webpack')

const { VueLoaderPlugin } = require('vue-loader')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin')
const WebpackNotifierPlugin = require('webpack-notifier')
const ManifestPlugin = require('webpack-manifest-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

const hmr = process.argv.includes('--hot')
const production = process.env.NODE_ENV === 'production'
const devServerPort = parseInt(process.env.DEV_SERVER_PORT || '8080', 10)
const devServerUrl = process.env.DEV_SERVER_URL || 'http://localhost:8080'

const publicPathFolder = production ? '/dist/' : '/build/'
const publicPath = hmr ? `${devServerUrl}${publicPathFolder}` : publicPathFolder

function getEntryConfig (name, analyzerPort, alias = {}) {
  let plugins = [
    new VueLoaderPlugin(),
    new webpack.IgnorePlugin(/jsdom$/),
    new FriendlyErrorsWebpackPlugin(),
    new WebpackNotifierPlugin(),
    new MiniCssExtractPlugin({
      filename: production ? 'css/[name].[chunkhash].css' : 'css/[name].css'
    }),
    new ManifestPlugin({
      fileName: `manifest-${name}.json`,
      publicPath,
      writeToFileEmit: true
    })
  ]

  if (production) {
    plugins.push(...[
      new BundleAnalyzerPlugin({
        analyzerPort
      })
    ])
  }

  let postcssPlugins = [
    require('autoprefixer')()
  ]

  if (production) {
    postcssPlugins.push(require('cssnano')())
  }

  let cssLoaders = [
    hmr ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
    {
      loader: 'css-loader',
      options: {
        sourceMap: true
      }
    }, {
      loader: 'postcss-loader',
      options: {
        ident: 'postcss',
        sourceMap: true,
        plugins: postcssPlugins
      }
    }
  ]

  return {
    entry: {
      [name]: [
        `./resources/js/${name}/app.js`,
        `./resources/sass/${name}/app.scss`
      ]
    },
    output: {
      path: path.resolve(__dirname, 'public' + publicPathFolder),
      filename: production ? 'js/[name].[chunkhash].js' : 'js/[name].js',
      publicPath
    },
    module: {
      rules: [
        {
          test: /\.css$/,
          use: cssLoaders
        },
        {
          test: /\.scss$/,
          use: cssLoaders.concat([
            {
              loader: 'resolve-url-loader'
            }, {
              loader: 'sass-loader',
              options: {
                outputStyle: 'expanded',
                sourceMap: true
              }
            }
          ])
        },
        {
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          enforce: 'pre'
        },
        {
          test: /\.vue$/,
          loader: 'vue-loader'
        },
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        },
        {
          test: /\.(png|jpe?g|gif)$/,
          use: [
            {
              loader: 'url-loader',
              options: {
                name: (path) => {
                  if (!/node_modules/.test(path)) {
                    return 'images/[name].[ext]?[hash]'
                  }

                  return `images/vendor-${name}/` + path
                    .replace(/\\/g, '/')
                    .replace(
                      /((.*(node_modules))|images|image|img|assets)\//g, ''
                    ) + '?[hash]'
                },
                limit: 4096
              }
            }
          ]
        },
        {
          test: /\.(woff2?|ttf|eot|svg|otf)$/,
          loader: 'url-loader',
          options: {
            name: (path) => {
              if (!/node_modules/.test(path)) {
                return 'fonts/[name].[ext]?[hash]'
              }

              return `fonts/vendor-${name}/[name].[ext]?[hash]`
            },
            limit: 4096
          }
        }
      ]
    },
    optimization: {
      splitChunks: {
        cacheGroups: {
          vendor: {
            test: /node_modules.*\.js$/,
            name: `vendor-${name}`,
            chunks: 'all'
          }
        }
      }
    },
    plugins,
    resolve: {
      extensions: ['.js', '.vue', '.json'],
      alias: Object.assign({
        'sweetalert2$': 'sweetalert2/dist/sweetalert2.js'
      }, alias)
    },
    externals: {
      jquery: 'jQuery',
      'popper.js': 'Popper'
    },
    devtool: production ? 'source-map' : 'cheap-module-eval-source-map',
    devServer: {
      contentBase: path.resolve(__dirname, 'public'),
      headers: {
        'Access-Control-Allow-Origin': '*'
      },
      watchOptions: {
        aggregateTimeout: 300,
        poll: 1000,
        ignored: /node_modules/
      },
      historyApiFallback: true,
      compress: true,
      noInfo: true,
      quiet: true,
      host: '0.0.0.0',
      port: devServerPort
    }
  }
}

module.exports = [
  getEntryConfig('frontend', 8888, {
    'vue$': 'vue/dist/vue.esm.js'
  }),
  getEntryConfig('backend', 8889)
]
<|endoftext|>


<commit_before>const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const exportVarName = process.env.EXPORT_VAR_NAME || "h4p";
const cssPrefix = process.env.CSS_PREFIX || (exportVarName + "__");

const CORE_VERSION = 'alpha-28';
const CORE_NAME = 'h4p-' + CORE_VERSION;

const config = {
  entry: {
    h4p: './src/main', // for npm
  },
  output: {
    path: __dirname + '/dist/',
    filename: '[name].js',
    library: exportVarName,
    libraryTarget: 'umd',
  },
  module: {
    loaders: [
      {
        test: /\.(jsx?)$/,
        loaders: ["babel"],
        exclude: /node_modules|lib/,
      },
      {
        test: /\.css$/,
        loaders: ["style", "css"]
      },
      {
        test: /\.html$/,
        loaders: ["handlebars"]
      },
      {
        test: /\.json$/,
        loaders: ["json"]
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.jsx', '.html', '.json'],
    modules: [
      path.resolve('./src'),
      'node_modules'
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      CSS_PREFIX: JSON.stringify(cssPrefix),
      EXPORT_VAR_NAME: JSON.stringify(exportVarName),
      CORE_VERSION: JSON.stringify(CORE_VERSION),
      CORE_CDN_URL: JSON.stringify(`https://embed.hackforplay.xyz/open-source/core/${CORE_NAME}.js`)
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false
    })
  ],
  devServer: {
    contentBase: 'dist',
    port: process.env.PORT
  },
};

if (process.env.NODE_ENV === 'production') {

  // for browser (& upload CDN)
  config.entry[CORE_NAME] = config.entry.h4p;
}

module.exports = config;
<commit_msg>CORE_CDN_PREFIX<commit_after>const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const exportVarName = process.env.EXPORT_VAR_NAME || "h4p";
const cssPrefix = process.env.CSS_PREFIX || (exportVarName + "__");

const CORE_VERSION = 'alpha-28';
const corePrefix = 'h4p-';
const CORE_NAME = corePrefix + CORE_VERSION;
const CORE_CDN_PREFIX = 'https://embed.hackforplay.xyz/open-source/core/' + corePrefix;

const config = {
  entry: {
    h4p: './src/main', // for npm
  },
  output: {
    path: __dirname + '/dist/',
    filename: '[name].js',
    library: exportVarName,
    libraryTarget: 'umd',
  },
  module: {
    loaders: [
      {
        test: /\.(jsx?)$/,
        loaders: ["babel"],
        exclude: /node_modules|lib/,
      },
      {
        test: /\.css$/,
        loaders: ["style", "css"]
      },
      {
        test: /\.html$/,
        loaders: ["handlebars"]
      },
      {
        test: /\.json$/,
        loaders: ["json"]
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.jsx', '.html', '.json'],
    modules: [
      path.resolve('./src'),
      'node_modules'
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      CSS_PREFIX: JSON.stringify(cssPrefix),
      EXPORT_VAR_NAME: JSON.stringify(exportVarName),
      CORE_VERSION: JSON.stringify(CORE_VERSION),
      CORE_CDN_PREFIX: JSON.stringify(CORE_CDN_PREFIX),
      CORE_CDN_URL: JSON.stringify(`${CORE_CDN_PREFIX}${CORE_NAME}.js`)
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false
    })
  ],
  devServer: {
    contentBase: 'dist',
    port: process.env.PORT
  },
};

if (process.env.NODE_ENV === 'production') {

  // for browser (& upload CDN)
  config.entry[CORE_NAME] = config.entry.h4p;
}

module.exports = config;
<|endoftext|>


<commit_before>/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';

var path = require('path');
// var webpack = require('webpack');

module.exports = {
  cache: true,
  entry: {
    main: './src/main.tsx',
    vendor: [
      'react/react',
      'react-dom',
      'react-addons-pure-render-mixin',
      'flux',
      'events',
      'babel/polyfill'
    ]
  },
  output: {
    path: path.resolve(__dirname, './dist/scripts'),
    filename: '[name].js',
    chunkFilename: '[chunkhash].js'
  },
  module: {
    loaders: [{
      test: /\.ts(x?)$/,
      exclude: /node_modules/,
      loader: 'babel-loader!ts-loader'
    }, {
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'babel'
    }]
  },
  plugins: [
  ],
  resolve: {
    // Add `.ts` and `.tsx` as a resolvable extension.
    extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
  },
};
<commit_msg>react-mixin goes to vendor<commit_after>/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';

var path = require('path');
// var webpack = require('webpack');

module.exports = {
  cache: true,
  entry: {
    main: './src/main.tsx',
    vendor: [
      'react/react',
      'react-dom',
      'react-addons-pure-render-mixin',
      'react-mixin',
      'flux',
      'events',
      'babel/polyfill'
    ]
  },
  output: {
    path: path.resolve(__dirname, './dist/scripts'),
    filename: '[name].js',
    chunkFilename: '[chunkhash].js'
  },
  module: {
    loaders: [{
      test: /\.ts(x?)$/,
      exclude: /node_modules/,
      loader: 'babel-loader!ts-loader'
    }, {
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'babel'
    }]
  },
  plugins: [
  ],
  resolve: {
    // Add `.ts` and `.tsx` as a resolvable extension.
    extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
  },
};
<|endoftext|>


<commit_before>var path              = require( 'path' );
var webpack           = require( 'webpack' );
var merge             = require( 'webpack-merge' );
var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
var autoprefixer      = require( 'autoprefixer' );
var ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
var CopyWebpackPlugin = require( 'copy-webpack-plugin' );
var entryPath         = path.join( __dirname, 'static/js/index.js' );
var outputPath        = path.join( __dirname, 'dist' );

console.log( 'WEBPACK GO!');

// determine build env
var TARGET_ENV = process.env.npm_lifecycle_event === 'build' ? 'production' : 'development';
var outputFilename = TARGET_ENV === 'production' ? '[name]-[hash].js' : '[name].js'

// common webpack config
var commonConfig = {

  output: {
    path:       outputPath,
    filename: `/static/js/${outputFilename}`,
    // publicPath: '/'
  },

  resolve: {
    extensions: ['', '.js', '.elm']
  },

  module: {
    noParse: /\.elm$/,
    loaders: [
      {
        test: /\.(eot|ttf|woff|woff2|svg)$/,
        loader: 'file-loader'
      }
    ]
  },

  plugins: [
    new HtmlWebpackPlugin({
      template: 'static/index.html',
      inject:   'body',
      filename: 'index.html'
    })
  ],

  postcss: [ autoprefixer( { browsers: ['last 2 versions'] } ) ],

}

// additional webpack settings for local env (when invoked by 'npm start')
if ( TARGET_ENV === 'development' ) {
  console.log( 'Serving locally...');

  module.exports = merge( commonConfig, {

    entry: [
      'webpack-dev-server/client?http://localhost:8000',
      entryPath
    ],

    devServer: {
      // serve index.html in place of 404 responses
      historyApiFallback: true,
      contentBase: './src',
    },

    module: {
      loaders: [
        {
          test:    /\.elm$/,
          exclude: [/elm-stuff/, /node_modules/],
          loader:  'elm-hot!elm-webpack?verbose=true&warn=true&debug=true'
        },
        {
          test: /\.(css|scss)$/,
          loaders: [
            'style-loader',
            'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
            'postcss-loader',
          ]
        }
      ]
    }

  });
}

// additional webpack settings for prod env (when invoked via 'npm run build')
if ( TARGET_ENV === 'production' ) {
  console.log( 'Building for prod...');

  module.exports = merge( commonConfig, {

    entry: entryPath,

    module: {
      loaders: [
        {
          test:    /\.elm$/,
          exclude: [/elm-stuff/, /node_modules/],
          loader:  'elm-webpack'
        },
        {
          test: /\.(css|scss)$/,
          loader: ExtractTextPlugin.extract( 'style-loader', [
            'css-loader',
            'postcss-loader',
          ])
        }
      ]
    },

    plugins: [
      new CopyWebpackPlugin([
        {
          from: 'static/img/',
          to:   'static/img/'
        },
        {
          from: 'favicon.ico'
        },
      ]),

      new webpack.optimize.OccurenceOrderPlugin(),

      // extract CSS into a separate file
      new ExtractTextPlugin( 'static/css/[name]-[hash].css', { allChunks: true } ),

      // minify & mangle JS/CSS
      new webpack.optimize.UglifyJsPlugin({
          minimize:   true,
          compressor: { warnings: false }
          // mangle:  true
      })
    ]

  });
}
<commit_msg>Fix webpack source path<commit_after>var path              = require( 'path' );
var webpack           = require( 'webpack' );
var merge             = require( 'webpack-merge' );
var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
var autoprefixer      = require( 'autoprefixer' );
var ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
var CopyWebpackPlugin = require( 'copy-webpack-plugin' );
var entryPath         = path.join( __dirname, 'static/js/index.js' );
var outputPath        = path.join( __dirname, 'dist' );

console.log( 'WEBPACK GO!');

// determine build env
var TARGET_ENV = process.env.npm_lifecycle_event === 'build' ? 'production' : 'development';
var outputFilename = TARGET_ENV === 'production' ? '[name]-[hash].js' : '[name].js'

// common webpack config
var commonConfig = {

  output: {
    path:       outputPath,
    filename: `/static/js/${outputFilename}`,
    // publicPath: '/'
  },

  resolve: {
    extensions: ['', '.js', '.elm']
  },

  module: {
    noParse: /\.elm$/,
    loaders: [
      {
        test: /\.(eot|ttf|woff|woff2|svg)$/,
        loader: 'file-loader'
      }
    ]
  },

  plugins: [
    new HtmlWebpackPlugin({
      template: 'static/index.html',
      inject:   'body',
      filename: 'index.html'
    })
  ],

  postcss: [ autoprefixer( { browsers: ['last 2 versions'] } ) ],

}

// additional webpack settings for local env (when invoked by 'npm start')
if ( TARGET_ENV === 'development' ) {
  console.log( 'Serving locally...');

  module.exports = merge( commonConfig, {

    entry: [
      'webpack-dev-server/client?http://localhost:8000',
      entryPath
    ],

    devServer: {
      // serve index.html in place of 404 responses
      historyApiFallback: true,
      contentBase: '.',
    },

    module: {
      loaders: [
        {
          test:    /\.elm$/,
          exclude: [/elm-stuff/, /node_modules/],
          loader:  'elm-hot!elm-webpack?verbose=true&warn=true&debug=true'
        },
        {
          test: /\.(css|scss)$/,
          loaders: [
            'style-loader',
            'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
            'postcss-loader',
          ]
        }
      ]
    }

  });
}

// additional webpack settings for prod env (when invoked via 'npm run build')
if ( TARGET_ENV === 'production' ) {
  console.log( 'Building for prod...');

  module.exports = merge( commonConfig, {

    entry: entryPath,

    module: {
      loaders: [
        {
          test:    /\.elm$/,
          exclude: [/elm-stuff/, /node_modules/],
          loader:  'elm-webpack'
        },
        {
          test: /\.(css|scss)$/,
          loader: ExtractTextPlugin.extract( 'style-loader', [
            'css-loader',
            'postcss-loader',
          ])
        }
      ]
    },

    plugins: [
      new CopyWebpackPlugin([
        {
          from: 'static/img/',
          to:   'static/img/'
        },
        {
          from: 'favicon.ico'
        },
      ]),

      new webpack.optimize.OccurenceOrderPlugin(),

      // extract CSS into a separate file
      new ExtractTextPlugin( 'static/css/[name]-[hash].css', { allChunks: true } ),

      // minify & mangle JS/CSS
      new webpack.optimize.UglifyJsPlugin({
          minimize:   true,
          compressor: { warnings: false }
          // mangle:  true
      })
    ]

  });
}
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var CleanWebpackPlugin = require('clean-webpack-plugin');

var reactExternal = {
    root: 'React',
    commonjs2: 'react',
    commonjs: 'react',
    amd: 'react'
};

var reduxExternal = {
    root: 'Redux',
    commonjs2: 'redux',
    commonjs: 'redux',
    amd: 'redux'
};

var reactReduxExternal = {
    root: 'ReactRedux',
    commonjs2: 'react-redux',
    commonjs: 'react-redux',
    amd: 'react-redux'
};

var joiExternal = {
    root: 'Joi',
    commonjs2: 'joi',
    commonjs: 'joi',
    amd: 'joi'
};

const webpackConfig = {
    entry: [
        './src/index.js'
    ],
    externals: {
        react: reactExternal,
        redux: reduxExternal,
        'react-redux': reactReduxExternal,
        joi: joiExternal
    },
    output: {
        path: require("path").resolve("./lib"),
        filename: 'modular-redux-form.js',
        // publicPath: '/'
    },
    module: {
        rules: [
            {
                test: /\.(?:jsx|js)$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
        }),
        new CleanWebpackPlugin(['lib'], {
            verbose: true
        }),
    ]
};

if(process.env.NODE_ENV !== 'production') {
    webpackConfig.devtool = 'source-map';
}
else if(process.env.NODE_ENV === 'production') {
    webpackConfig.plugins.push(
        new webpack.optimize.UglifyJsPlugin({
             sourceMap: true
        })
    );
}

module.exports = webpackConfig;
<commit_msg>prepare fix 1<commit_after>var path = require('path');
var webpack = require('webpack');
var CleanWebpackPlugin = require('clean-webpack-plugin');

var reactExternal = {
    root: 'React',
    commonjs2: 'react',
    commonjs: 'react',
    amd: 'react'
};

var reduxExternal = {
    root: 'Redux',
    commonjs2: 'redux',
    commonjs: 'redux',
    amd: 'redux'
};

var reactReduxExternal = {
    root: 'ReactRedux',
    commonjs2: 'react-redux',
    commonjs: 'react-redux',
    amd: 'react-redux'
};

var joiExternal = {
    root: 'Joi',
    commonjs2: 'joi',
    commonjs: 'joi',
    amd: 'joi'
};

const webpackConfig = {
    entry: [
        './src/index.js'
    ],
    externals: {
        react: reactExternal,
        redux: reduxExternal,
        'react-redux': reactReduxExternal,
        joi: joiExternal
    },
    output: {
        path: require("path").resolve("./lib"),
        filename: 'modular-redux-form.js',
        library: '@mzvonar/modular-redux-form',
        libraryTarget: 'umd'
    },
    module: {
        rules: [
            {
                test: /\.(?:jsx|js)$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
        }),
        new CleanWebpackPlugin(['lib'], {
            verbose: true
        }),
    ]
};

if(process.env.NODE_ENV !== 'production') {
    webpackConfig.devtool = 'source-map';
}
else if(process.env.NODE_ENV === 'production') {
    webpackConfig.plugins.push(
        new webpack.optimize.UglifyJsPlugin({
             sourceMap: true
        })
    );
}

module.exports = webpackConfig;
<|endoftext|>


<commit_before>var webpack = require('webpack')
var generate = function(isProd) {
    return {
        entry: {
            'sir-trevor-adapter': './src/index.js',
        },
        output: {
            library: 'SirTrevorAdapter',
            libraryTarget: 'umd',
            filename: '[name].' + (isProd ? 'min.' : '') + 'js'
        },
        plugins: isProd ? [ new webpack.optimize.UglifyJsPlugin() ] : [],
        externals: {
            jquery: {
                commonjs: 'jquery',
                amd: 'jquery',
                root: 'jQuery'
            }
        }
    }
}

module.exports = generate(false)
module.exports.generate = generate<commit_msg>Also add commonjs2 to the module requirement system<commit_after>var webpack = require('webpack')
var generate = function(isProd) {
    return {
        entry: {
            'sir-trevor-adapter': './src/index.js',
        },
        output: {
            library: 'SirTrevorAdapter',
            libraryTarget: 'umd',
            filename: '[name].' + (isProd ? 'min.' : '') + 'js'
        },
        plugins: isProd ? [ new webpack.optimize.UglifyJsPlugin() ] : [],
        externals: {
            jquery: {
                commonjs: 'jquery',
                commonjs2: 'jquery',
                amd: 'jquery',
                root: 'jQuery'
            }
        }
    }
}

module.exports = generate(false)
module.exports.generate = generate<|endoftext|>


<commit_before>'use strict'

var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin')
var DashboardPlugin = require('webpack-dashboard/plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var merge = require('webpack-merge')
var path = require('path')
var WebpackChunkHash = require('webpack-chunk-hash')
var WebpackCleanupPlugin = require('webpack-cleanup-plugin')
var webpack = require('webpack')

const baseConfig = () => ({
  entry: [
    path.join(__dirname, '/src/index.js')
  ],
  resolve: {
    extensions: ['.js']
  },
  module: {
    rules: [
      {
        test: /\.js?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'babel-loader'
      },
      {
        test: /\.css$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            {
              loader: 'css-loader',
              options: {
                importLoaders: 1,
                modules: true,
                minimize: true
              }
            },
            'postcss-loader'
          ]
        })
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'file-loader'
      },
      {
        test: /\.(woff|woff2)$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?prefix=font/&limit=5000'
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
      },
      {
        test: /\.gif/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/gif'
      },
      {
        test: /\.jpg/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/jpg'
      },
      {
        test: /\.png/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/png'
      }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: ['vendor'],
      minChunks: function (module) {
        return module.context && module.context.indexOf('node_modules') !== -1
      }
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'manifest'
    }),
    new webpack.HashedModuleIdsPlugin(),
    new WebpackChunkHash(),
    new ChunkManifestPlugin({
      filename: 'chunk-manifest.json',
      manifestVariable: 'webpackManifest'
    }),
    new ExtractTextPlugin({
      filename: '[name].css',
      allChunks: true
    }),
    new HtmlWebpackPlugin({
      template: './src/template.html',
      favicon: './src/images/favicon.png'
    })
  ]
})

const configProd = (base) => merge.smart(base(), {
  output: {
    publicPath: './',
    path: path.join(__dirname, 'public'),
    filename: '[name].[chunkhash].js'
  },
  devtool: 'source-map',
  plugins: [
    new WebpackCleanupPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      comments: false
    }),
    new webpack.optimize.OccurrenceOrderPlugin()
  ]
})

const configDev = (base) => merge.smartStrategy({ entry: 'prepend' })(base(), {
  entry: [
    // activate HMR for React
    'react-hot-loader/patch',

    // bundle the client for webpack-dev-server
    // and connect to the provided endpoint
    'webpack-dev-server/client?http://localhost:8888',

    // bundle the client for hot reloading
    // only- means to only hot reload for successful updates
    'webpack/hot/only-dev-server'
  ],
  output: {
    // necessary for HMR to know where to load the hot update chunks
    publicPath: '/',

    path: path.join(__dirname, 'public'),

    filename: '[name].js'
  },
  devtool: 'inline-source-map',
  devServer: {
    host: 'localhost',
    port: 8888,

    contentBase: path.resolve(__dirname, 'public'),

    // serve index.html in place of 404 responses to allow HTML5 history
    historyApiFallback: true,

    // enable HMR
    hot: true,

    // embed the webpack-dev-server runtime into the bundle
    inline: true,

    publicPath: '/'
  },
  plugins: [
    // enable HMR globally
    new webpack.HotModuleReplacementPlugin(),

    // more readable module names in the browser console on HMR updates
    new webpack.NamedModulesPlugin(),

    // do not emit compiled assets that include errors
    new webpack.NoEmitOnErrorsPlugin(),

    new DashboardPlugin()
  ]
})

const config = (env) =>
  (env === 'production') ? configProd(baseConfig) : configDev(baseConfig)

module.exports = config
<commit_msg>enable intranet access on webpack dev server<commit_after>'use strict'

var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin')
var DashboardPlugin = require('webpack-dashboard/plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var merge = require('webpack-merge')
var path = require('path')
var WebpackChunkHash = require('webpack-chunk-hash')
var WebpackCleanupPlugin = require('webpack-cleanup-plugin')
var webpack = require('webpack')

const baseConfig = () => ({
  entry: [
    path.join(__dirname, '/src/index.js')
  ],
  resolve: {
    extensions: ['.js']
  },
  module: {
    rules: [
      {
        test: /\.js?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'babel-loader'
      },
      {
        test: /\.css$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            {
              loader: 'css-loader',
              options: {
                importLoaders: 1,
                modules: true,
                minimize: true
              }
            },
            'postcss-loader'
          ]
        })
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'file-loader'
      },
      {
        test: /\.(woff|woff2)$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?prefix=font/&limit=5000'
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
      },
      {
        test: /\.gif/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/gif'
      },
      {
        test: /\.jpg/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/jpg'
      },
      {
        test: /\.png/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        loader: 'url-loader?limit=10000&mimetype=image/png'
      }
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: ['vendor'],
      minChunks: function (module) {
        return module.context && module.context.indexOf('node_modules') !== -1
      }
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'manifest'
    }),
    new webpack.HashedModuleIdsPlugin(),
    new WebpackChunkHash(),
    new ChunkManifestPlugin({
      filename: 'chunk-manifest.json',
      manifestVariable: 'webpackManifest'
    }),
    new ExtractTextPlugin({
      filename: '[name].css',
      allChunks: true
    }),
    new HtmlWebpackPlugin({
      template: './src/template.html',
      favicon: './src/images/favicon.png'
    })
  ]
})

const configProd = (base) => merge.smart(base(), {
  output: {
    publicPath: './',
    path: path.join(__dirname, 'public'),
    filename: '[name].[chunkhash].js'
  },
  devtool: 'source-map',
  plugins: [
    new WebpackCleanupPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      comments: false
    }),
    new webpack.optimize.OccurrenceOrderPlugin()
  ]
})

const configDev = (base) => merge.smartStrategy({ entry: 'prepend' })(base(), {
  entry: [
    // activate HMR for React
    'react-hot-loader/patch',

    // bundle the client for webpack-dev-server
    // and connect to the provided endpoint
    'webpack-dev-server/client?http://localhost:12335',

    // bundle the client for hot reloading
    // only- means to only hot reload for successful updates
    'webpack/hot/only-dev-server'
  ],
  output: {
    // necessary for HMR to know where to load the hot update chunks
    publicPath: '/',

    path: path.join(__dirname, 'public'),

    filename: '[name].js'
  },
  devtool: 'inline-source-map',
  devServer: {
    host: '0.0.0.0',
    port: 12335,

    contentBase: path.resolve(__dirname, 'public'),

    // serve index.html in place of 404 responses to allow HTML5 history
    historyApiFallback: true,

    // enable HMR
    hot: true,

    // embed the webpack-dev-server runtime into the bundle
    inline: true,

    publicPath: '/'
  },
  plugins: [
    // enable HMR globally
    new webpack.HotModuleReplacementPlugin(),

    // more readable module names in the browser console on HMR updates
    new webpack.NamedModulesPlugin(),

    // do not emit compiled assets that include errors
    new webpack.NoEmitOnErrorsPlugin(),

    new DashboardPlugin()
  ]
})

const config = (env) =>
  (env === 'production') ? configProd(baseConfig) : configDev(baseConfig)

module.exports = config
<|endoftext|>


<commit_before>/// <reference path='./typings/index.d.ts'/>

'use strict';

const assert = require('assert');

const isRelease = process.env.NODE_ENV === 'production';

const KAREN_ENTRY_POINT = process.env.KAREN_ENTRY_POINT;
assert.ok(!!KAREN_ENTRY_POINT, 'not found process.env.KAREN_ENTRY_POINT');

const KAREN_CLIENT_DIST_DIR = process.env.KAREN_CLIENT_DIST_DIR;
assert.ok(!!KAREN_CLIENT_DIST_DIR, 'not found process.env.KAREN_CLIENT_DIST_DIR');

const babelPresets = [
];

let babelPlugins = [
    // For our target browsers, we need not some transforms.
    'transform-es2015-arrow-functions',
    'transform-es2015-block-scoped-functions',
    'transform-es2015-block-scoping',
    'transform-es2015-classes',
    'transform-es2015-computed-properties',
    'check-es2015-constants',
    'transform-es2015-destructuring',
    'transform-es2015-function-name',
    'transform-es2015-modules-commonjs',
    'transform-es2015-object-super',
    'transform-es2015-parameters',
    'transform-es2015-spread',
    'transform-es2015-sticky-regex',
    'transform-es2015-unicode-regex',
    'transform-regenerator',

    // for React
    'syntax-jsx',
    'transform-react-jsx',

    // some utilitis
    'transform-inline-environment-variables',
    'transform-node-env-inline',
];

if (isRelease) {
    babelPlugins = babelPlugins.concat([
        'transform-react-constant-elements',
        'transform-react-inline-elements',
    ]);
}
else {
    babelPlugins = babelPlugins.concat([
        'transform-react-jsx-source',
    ]);
}

module.exports = {
    bail: true,

    devtool: isRelease ? '' : 'inline-source-map',

    entry: {
        karen: KAREN_ENTRY_POINT,
    },

    output: {
        path: KAREN_CLIENT_DIST_DIR,
        filename: '[name].js',
    },

    resolve: {
        alias: {},
        root: [],
        extensions: ['', '.js', '.jsx'],
        modulesDirectories: ['node_modules'],
    },

    module: {
        loaders: [
            {
                test: /\.jsx?$/, // loader is applied to files which matches this extensions.
                exclude: /node_modules/, // don't transform under this path.
                loader: 'babel-loader',
                query: {
                    presets: babelPresets,
                    plugins: babelPlugins,
                }
            }
        ]
    },
};
<commit_msg>feat(build): generate the source-map file instead on the inlined one.<commit_after>/// <reference path='./typings/index.d.ts'/>

'use strict';

const assert = require('assert');

const isRelease = process.env.NODE_ENV === 'production';

const KAREN_ENTRY_POINT = process.env.KAREN_ENTRY_POINT;
assert.ok(!!KAREN_ENTRY_POINT, 'not found process.env.KAREN_ENTRY_POINT');

const KAREN_CLIENT_DIST_DIR = process.env.KAREN_CLIENT_DIST_DIR;
assert.ok(!!KAREN_CLIENT_DIST_DIR, 'not found process.env.KAREN_CLIENT_DIST_DIR');

const babelPresets = [
];

let babelPlugins = [
    // For our target browsers, we need not some transforms.
    'transform-es2015-arrow-functions',
    'transform-es2015-block-scoped-functions',
    'transform-es2015-block-scoping',
    'transform-es2015-classes',
    'transform-es2015-computed-properties',
    'check-es2015-constants',
    'transform-es2015-destructuring',
    'transform-es2015-function-name',
    'transform-es2015-modules-commonjs',
    'transform-es2015-object-super',
    'transform-es2015-parameters',
    'transform-es2015-spread',
    'transform-es2015-sticky-regex',
    'transform-es2015-unicode-regex',
    'transform-regenerator',

    // for React
    'syntax-jsx',
    'transform-react-jsx',

    // some utilitis
    'transform-inline-environment-variables',
    'transform-node-env-inline',
];

if (isRelease) {
    babelPlugins = babelPlugins.concat([
        'transform-react-constant-elements',
        'transform-react-inline-elements',
    ]);
}
else {
    babelPlugins = babelPlugins.concat([
        'transform-react-jsx-source',
    ]);
}

module.exports = {
    bail: true,

    devtool: isRelease ? '' : 'source-map',

    entry: {
        karen: KAREN_ENTRY_POINT,
    },

    output: {
        path: KAREN_CLIENT_DIST_DIR,
        filename: '[name].js',
    },

    resolve: {
        alias: {},
        root: [],
        extensions: ['', '.js', '.jsx'],
        modulesDirectories: ['node_modules'],
    },

    module: {
        loaders: [
            {
                test: /\.jsx?$/, // loader is applied to files which matches this extensions.
                exclude: /node_modules/, // don't transform under this path.
                loader: 'babel-loader',
                query: {
                    presets: babelPresets,
                    plugins: babelPlugins,
                }
            }
        ]
    },
};
<|endoftext|>


<commit_before>var ExtractTextPlugin = require("extract-text-webpack-plugin");
var CleanCSSPlugin = require("less-plugin-clean-css");
var AutoprefixPlugin = require("less-plugin-autoprefix");

module.exports = {
    entry: [
        "./src/js/main.ts",
        "./src/style.less"
    ],
    output: {
        path: __dirname+"/src/js/",
        filename: "main-build.js"
    },
    resolve: {
        extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
    },
    plugins: [
        new ExtractTextPlugin("../style.css")
    ],
    module: {
        loaders: [
            { test: /\.tsx?$/, loader: "ts-loader" },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract({ use: 'css-loader' })
            },
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract({
                    use: [
                        {
                            loader: "css-loader",
                            options: { url: false }
                        },
                        {
                            loader: "less-loader",
                            options: {
                                plugins: [
                                    new CleanCSSPlugin({advanced: true}),
                                    new AutoprefixPlugin()
                                ]
                            }
                        }
                    ]
                })
            }
        ]
    }
};
<commit_msg>* Capitalize drive letter on windows as workaround for webpack bug https://github.com/webpack/webpack/issues/4530<commit_after>var ExtractTextPlugin = require("extract-text-webpack-plugin");
var CleanCSSPlugin = require("less-plugin-clean-css");
var AutoprefixPlugin = require("less-plugin-autoprefix");

/*
 * Capitalize drive letter on windows as workaround for
 * webpack bug.
 * https://github.com/webpack/webpack/issues/4530
 */
var outputPath = path.resolve(__dirname, 'src/js/');
outputPath = outputPath.charAt(0).toUpperCase() + outputPath.slice(1);

module.exports = {
    entry: [
        "./src/js/main.ts",
        "./src/style.less"
    ],
    output: {
        path: outputPath,
        filename: "main-build.js"
    },
    resolve: {
        extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
    },
    plugins: [
        new ExtractTextPlugin("../style.css")
    ],
    module: {
        loaders: [
            { test: /\.tsx?$/, loader: "ts-loader" },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract({ use: 'css-loader' })
            },
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract({
                    use: [
                        {
                            loader: "css-loader",
                            options: { url: false }
                        },
                        {
                            loader: "less-loader",
                            options: {
                                plugins: [
                                    new CleanCSSPlugin({advanced: true}),
                                    new AutoprefixPlugin()
                                ]
                            }
                        }
                    ]
                })
            }
        ]
    }
};
<|endoftext|>


<commit_before>/**
 * Webpack config.
 *
 * Site Kit by Google, Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Node dependencies
 */
const fs = require( 'fs' );
const path = require( 'path' );

/**
 * External dependencies
 */
const CircularDependencyPlugin = require( 'circular-dependency-plugin' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const WebpackBar = require( 'webpackbar' );
const { ProvidePlugin } = require( 'webpack' );

const projectPath = ( relativePath ) => {
	return path.resolve( fs.realpathSync( process.cwd() ), relativePath );
};

const noAMDParserRule = { parser: { amd: false } };

const siteKitExternals = {
	'googlesitekit-api': [ 'googlesitekit', 'api' ],
	'googlesitekit-data': [ 'googlesitekit', 'data' ],
	'googlesitekit-modules': [ 'googlesitekit', 'modules' ],
	'googlesitekit-widgets': [ 'googlesitekit', 'widgets' ],
};

const externals = { ...siteKitExternals };

const rules = [
	noAMDParserRule,
	{
		test: /\.js$/,
		exclude: /node_modules/,
		use: [
			{
				loader: 'babel-loader',
				query: {
					presets: [ [ '@babel/env', {
						useBuiltIns: 'entry',
						corejs: 2,
					} ], '@babel/preset-react' ],
				},
			},
			{
				loader: 'eslint-loader',
				options: {
					quiet: true,
					formatter: require( 'eslint' ).CLIEngine.getFormatter( 'stylish' ),
				},
			},
		],
		...noAMDParserRule,
	},
];

const resolve = {
	alias: {
		'@wordpress/api-fetch__non-shim': require.resolve( '@wordpress/api-fetch' ),
		'@wordpress/api-fetch$': path.resolve( 'assets/js/api-fetch-shim.js' ),
		'@wordpress/element__non-shim': require.resolve( '@wordpress/element' ),
		'@wordpress/element$': path.resolve( 'assets/js/element-shim.js' ),
		'@wordpress/hooks__non-shim': require.resolve( '@wordpress/hooks' ),
		'@wordpress/hooks$': path.resolve( 'assets/js/hooks-shim.js' ),
	},
	modules: [ projectPath( '.' ), 'node_modules' ],
};

const webpackConfig = ( mode ) => {
	return [
		// Build the settings js..
		{
			entry: {
				// New Modules (Post-JSR).
				'googlesitekit-api': './assets/js/googlesitekit-api.js',
				'googlesitekit-data': './assets/js/googlesitekit-data.js',
				'googlesitekit-datastore-site': './assets/js/googlesitekit-datastore-site.js',
				'googlesitekit-datastore-user': './assets/js/googlesitekit-datastore-user.js',
				'googlesitekit-datastore-forms': './assets/js/googlesitekit-datastore-forms.js',
				'googlesitekit-modules': './assets/js/googlesitekit-modules.js',
				'googlesitekit-widgets': './assets/js/googlesitekit-widgets.js',
				'googlesitekit-modules-adsense': './assets/js/googlesitekit-modules-adsense.js',
				'googlesitekit-modules-analytics': './assets/js/googlesitekit-modules-analytics.js',
				'googlesitekit-modules-pagespeed-insights': 'assets/js/googlesitekit-modules-pagespeed-insights.js',
				'googlesitekit-modules-search-console': './assets/js/googlesitekit-modules-search-console.js',
				'googlesitekit-modules-optimize': './assets/js/googlesitekit-modules-optimize.js',
				// Old Modules
				'googlesitekit-activation': './assets/js/googlesitekit-activation.js',
				'googlesitekit-settings': './assets/js/googlesitekit-settings.js',
				'googlesitekit-dashboard': './assets/js/googlesitekit-dashboard.js',
				'googlesitekit-dashboard-details': './assets/js/googlesitekit-dashboard-details.js',
				'googlesitekit-dashboard-splash': './assets/js/googlesitekit-dashboard-splash.js',
				'googlesitekit-wp-dashboard': './assets/js/googlesitekit-wp-dashboard.js',
				'googlesitekit-adminbar-loader': './assets/js/googlesitekit-adminbar-loader.js',
				'googlesitekit-admin': './assets/js/googlesitekit-admin.js',
				'googlesitekit-module': './assets/js/googlesitekit-module.js',
				// Needed to test if a browser extension blocks this by naming convention.
				'pagead2.ads': './assets/js/pagead2.ads.js',
			},
			externals,
			output: {
				filename: '[name].js',
				path: __dirname + '/dist/assets/js',
				chunkFilename: '[name]-[chunkhash].js',
				publicPath: '',
			},
			performance: {
				maxEntrypointSize: 175000,
			},
			module: {
				rules,
			},
			plugins: [
				new ProvidePlugin( {
					React: 'react',
				} ),
				new WebpackBar( {
					name: 'Module Entry Points',
					color: '#fbbc05',
				} ),
				new CircularDependencyPlugin( {
					exclude: /node_modules/,
					failOnError: true,
					allowAsyncCycles: false,
					cwd: process.cwd(),
				} ),
			],
			optimization: {
				minimizer: [
					new TerserPlugin( {
						parallel: true,
						sourceMap: false,
						cache: true,
						terserOptions: {
							// We preserve function names that start with capital letters as
							// they're _likely_ component names, and these are useful to have
							// in tracebacks and error messages.
							keep_fnames: /__|_x|_n|_nx|sprintf|^[A-Z].+$/,
							output: {
								comments: /translators:/i,
							},
						},
						extractComments: false,
					} ),
				],
				runtimeChunk: false,
				splitChunks: {
					cacheGroups: {
						vendor: {
							chunks: 'initial',
							name: 'googlesitekit-vendor',
							filename: 'googlesitekit-vendor.js',
							enforce: true,
							test: /[\\/]node_modules[\\/]/,
						},
					},
				},
			},
			resolve,
		},

		// Build the main plugin admin css.
		{
			entry: {
				admin: './assets/sass/admin.scss',
				adminbar: './assets/sass/adminbar.scss',
				wpdashboard: './assets/sass/wpdashboard.scss',
			},
			module: {
				rules: [
					{
						test: /\.scss$/,
						use: [
							MiniCssExtractPlugin.loader,
							{
								loader: 'css-loader',
								options: {
									minimize: ( 'production' === mode ),
								},
							},
							'postcss-loader',
							{
								loader: 'sass-loader',
								options: {
									includePaths: [ 'node_modules' ],
								},
							},
						],
					},
					{
						test: /\.(png|woff|woff2|eot|ttf|svg|gif)$/,
						use: { loader: 'url-loader?limit=100000' },
					},
				],
			},
			plugins: [
				new MiniCssExtractPlugin( {
					filename: '/assets/css/[name].css',
				} ),
				new WebpackBar( {
					name: 'Plugin CSS',
					color: '#4285f4',
				} ),
			],
		},
	];
};

const testBundle = () => {
	return {
		entry: {
			'e2e-utilities': './tests/e2e/e2e-utilities.js',
		},
		output: {
			filename: '[name].js',
			path: __dirname + '/dist/assets/js',
			chunkFilename: '[name].js',
			publicPath: '',
		},
		module: {
			rules,
		},
		plugins: [
			new WebpackBar( {
				name: 'Test files',
				color: '#34a853',
			} ),
		],
		externals,
		resolve,
	};
};

module.exports = {
	externals,
	noAMDParserRule,
	projectPath,
	resolve,
	rules,
	siteKitExternals,
};

module.exports.default = ( ...args ) => {
	const { includeTests, mode } = args[ 1 ];
	const config = webpackConfig( mode );

	if ( mode !== 'production' || includeTests ) {
		// Build the test files if we aren't doing a production build.
		config.push( testBundle() );
	}

	return config;
};
<commit_msg>Customize jsonpFunction in webpack.config.<commit_after>/**
 * Webpack config.
 *
 * Site Kit by Google, Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Node dependencies
 */
const fs = require( 'fs' );
const path = require( 'path' );

/**
 * External dependencies
 */
const CircularDependencyPlugin = require( 'circular-dependency-plugin' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const WebpackBar = require( 'webpackbar' );
const { ProvidePlugin } = require( 'webpack' );

const projectPath = ( relativePath ) => {
	return path.resolve( fs.realpathSync( process.cwd() ), relativePath );
};

const noAMDParserRule = { parser: { amd: false } };

const siteKitExternals = {
	'googlesitekit-api': [ 'googlesitekit', 'api' ],
	'googlesitekit-data': [ 'googlesitekit', 'data' ],
	'googlesitekit-modules': [ 'googlesitekit', 'modules' ],
	'googlesitekit-widgets': [ 'googlesitekit', 'widgets' ],
};

const externals = { ...siteKitExternals };

const rules = [
	noAMDParserRule,
	{
		test: /\.js$/,
		exclude: /node_modules/,
		use: [
			{
				loader: 'babel-loader',
				query: {
					presets: [ [ '@babel/env', {
						useBuiltIns: 'entry',
						corejs: 2,
					} ], '@babel/preset-react' ],
				},
			},
			{
				loader: 'eslint-loader',
				options: {
					quiet: true,
					formatter: require( 'eslint' ).CLIEngine.getFormatter( 'stylish' ),
				},
			},
		],
		...noAMDParserRule,
	},
];

const resolve = {
	alias: {
		'@wordpress/api-fetch__non-shim': require.resolve( '@wordpress/api-fetch' ),
		'@wordpress/api-fetch$': path.resolve( 'assets/js/api-fetch-shim.js' ),
		'@wordpress/element__non-shim': require.resolve( '@wordpress/element' ),
		'@wordpress/element$': path.resolve( 'assets/js/element-shim.js' ),
		'@wordpress/hooks__non-shim': require.resolve( '@wordpress/hooks' ),
		'@wordpress/hooks$': path.resolve( 'assets/js/hooks-shim.js' ),
	},
	modules: [ projectPath( '.' ), 'node_modules' ],
};

const webpackConfig = ( mode ) => {
	return [
		// Build the settings js..
		{
			entry: {
				// New Modules (Post-JSR).
				'googlesitekit-api': './assets/js/googlesitekit-api.js',
				'googlesitekit-data': './assets/js/googlesitekit-data.js',
				'googlesitekit-datastore-site': './assets/js/googlesitekit-datastore-site.js',
				'googlesitekit-datastore-user': './assets/js/googlesitekit-datastore-user.js',
				'googlesitekit-datastore-forms': './assets/js/googlesitekit-datastore-forms.js',
				'googlesitekit-modules': './assets/js/googlesitekit-modules.js',
				'googlesitekit-widgets': './assets/js/googlesitekit-widgets.js',
				'googlesitekit-modules-adsense': './assets/js/googlesitekit-modules-adsense.js',
				'googlesitekit-modules-analytics': './assets/js/googlesitekit-modules-analytics.js',
				'googlesitekit-modules-pagespeed-insights': 'assets/js/googlesitekit-modules-pagespeed-insights.js',
				'googlesitekit-modules-search-console': './assets/js/googlesitekit-modules-search-console.js',
				'googlesitekit-modules-optimize': './assets/js/googlesitekit-modules-optimize.js',
				// Old Modules
				'googlesitekit-activation': './assets/js/googlesitekit-activation.js',
				'googlesitekit-settings': './assets/js/googlesitekit-settings.js',
				'googlesitekit-dashboard': './assets/js/googlesitekit-dashboard.js',
				'googlesitekit-dashboard-details': './assets/js/googlesitekit-dashboard-details.js',
				'googlesitekit-dashboard-splash': './assets/js/googlesitekit-dashboard-splash.js',
				'googlesitekit-wp-dashboard': './assets/js/googlesitekit-wp-dashboard.js',
				'googlesitekit-adminbar-loader': './assets/js/googlesitekit-adminbar-loader.js',
				'googlesitekit-admin': './assets/js/googlesitekit-admin.js',
				'googlesitekit-module': './assets/js/googlesitekit-module.js',
				// Needed to test if a browser extension blocks this by naming convention.
				'pagead2.ads': './assets/js/pagead2.ads.js',
			},
			externals,
			output: {
				filename: '[name].js',
				path: __dirname + '/dist/assets/js',
				chunkFilename: '[name]-[chunkhash].js',
				publicPath: '',
				/**
				 * If multiple webpack runtimes (from different compilations) are used on the same webpage,
				 * there is a risk of conflicts of on-demand chunks in the global namespace.
				 *
				 * @see (@link https://webpack.js.org/configuration/output/#outputjsonpfunction)
				 */
				jsonpFunction: '__googlesitekit_webpackJsonp',
			},
			performance: {
				maxEntrypointSize: 175000,
			},
			module: {
				rules,
			},
			plugins: [
				new ProvidePlugin( {
					React: 'react',
				} ),
				new WebpackBar( {
					name: 'Module Entry Points',
					color: '#fbbc05',
				} ),
				new CircularDependencyPlugin( {
					exclude: /node_modules/,
					failOnError: true,
					allowAsyncCycles: false,
					cwd: process.cwd(),
				} ),
			],
			optimization: {
				minimizer: [
					new TerserPlugin( {
						parallel: true,
						sourceMap: false,
						cache: true,
						terserOptions: {
							// We preserve function names that start with capital letters as
							// they're _likely_ component names, and these are useful to have
							// in tracebacks and error messages.
							keep_fnames: /__|_x|_n|_nx|sprintf|^[A-Z].+$/,
							output: {
								comments: /translators:/i,
							},
						},
						extractComments: false,
					} ),
				],
				runtimeChunk: false,
				splitChunks: {
					cacheGroups: {
						vendor: {
							chunks: 'initial',
							name: 'googlesitekit-vendor',
							filename: 'googlesitekit-vendor.js',
							enforce: true,
							test: /[\\/]node_modules[\\/]/,
						},
					},
				},
			},
			resolve,
		},

		// Build the main plugin admin css.
		{
			entry: {
				admin: './assets/sass/admin.scss',
				adminbar: './assets/sass/adminbar.scss',
				wpdashboard: './assets/sass/wpdashboard.scss',
			},
			module: {
				rules: [
					{
						test: /\.scss$/,
						use: [
							MiniCssExtractPlugin.loader,
							{
								loader: 'css-loader',
								options: {
									minimize: ( 'production' === mode ),
								},
							},
							'postcss-loader',
							{
								loader: 'sass-loader',
								options: {
									includePaths: [ 'node_modules' ],
								},
							},
						],
					},
					{
						test: /\.(png|woff|woff2|eot|ttf|svg|gif)$/,
						use: { loader: 'url-loader?limit=100000' },
					},
				],
			},
			plugins: [
				new MiniCssExtractPlugin( {
					filename: '/assets/css/[name].css',
				} ),
				new WebpackBar( {
					name: 'Plugin CSS',
					color: '#4285f4',
				} ),
			],
		},
	];
};

const testBundle = () => {
	return {
		entry: {
			'e2e-utilities': './tests/e2e/e2e-utilities.js',
		},
		output: {
			filename: '[name].js',
			path: __dirname + '/dist/assets/js',
			chunkFilename: '[name].js',
			publicPath: '',
		},
		module: {
			rules,
		},
		plugins: [
			new WebpackBar( {
				name: 'Test files',
				color: '#34a853',
			} ),
		],
		externals,
		resolve,
	};
};

module.exports = {
	externals,
	noAMDParserRule,
	projectPath,
	resolve,
	rules,
	siteKitExternals,
};

module.exports.default = ( ...args ) => {
	const { includeTests, mode } = args[ 1 ];
	const config = webpackConfig( mode );

	if ( mode !== 'production' || includeTests ) {
		// Build the test files if we aren't doing a production build.
		config.push( testBundle() );
	}

	return config;
};
<|endoftext|>


<commit_before>var path = require('path');

module.exports = {
    entry: 'src/autobahn.js',
    resolve: {
        root: path.resolve('./dist/'),
        extensions: ['', '.json', '.js']
    },
    output: {
        path: __dirname + '/dist/browser/',
        filename: 'autobahn.js',

        // will be the global variable that the autobahn.js file exports to
        library: 'autobahn',
        libraryTarget: 'var'
    },
    externals: {
        // This *has* to exactly match the string as used in the require() statement including
        // the leading .
        "./transport/rawsocket": true,
        "./websocket-node": true,
        'net': true,
        'fs': true,
        'ws': true,
        'crypto-js': true,
    },
    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: 'json'
            }
        ]
    }
};
<commit_msg>Use umd as browser output format<commit_after>var path = require('path');
// TODO: browsers tests with actual autobahn.js bundled by the build tool
// (not identic copy)
module.exports = {
    entry: 'src/autobahn.js',
    resolve: {
        root: path.resolve('./dist/'),
        extensions: ['', '.json', '.js']
    },
    output: {
        path: __dirname + '/dist/browser/',
        filename: 'autobahn.js',

        // will be the global variable that the autobahn.js file exports to
        library: 'autobahn',
        libraryTarget: 'umd'
    },
    externals: {
        // This *has* to exactly match the string as used in the require() statement including
        // the leading .
        "./transport/rawsocket": true,
        "./websocket-node": true,
        'net': true,
        'fs': true,
        'ws': true,
        'crypto-js': true,
    },
    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: 'json'
            }
        ]
    }
};
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const HtmlPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');

// Environment

const isProduction = process.env.NODE_ENV === 'production';

// Paths

const src = path.join(__dirname, 'src');
const dist = path.join(__dirname, 'dist');

// Base configuration

const config = {
  entry: path.join(src, 'index.js'),

  output: {
    path: dist,
    publicPath: '/',
  },

  module: {
    loaders: [
      {
        test: /\.jss?$/,
        exclude: /node_modules/,
        loader: 'babel',
      },
      {
        test: /\.json$/,
        loader: 'json',
      },
    ],
  },

  plugins: [
    new webpack.EnvironmentPlugin(['NODE_ENV']),
    new HtmlPlugin({
      template: path.join(src, 'index.ejs'),
      inject: false,
      filename: 'index.html',
    }),
    new webpack.ProvidePlugin({
      fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
    }),
    new webpack.DefinePlugin({
      __DEV__: !isProduction,
    }),
  ],

  resolve: {
    extensions: ['', '.js', '.jss'],
  },
};

// Output configuration

config.output.filename = isProduction ? '[name]-[hash].js' : '[name].js';

// Development tools

config.devtool = isProduction ? 'source-map' : 'eval';

if (!isProduction) {
  config.output.pathinfo = true;
}

// CSS loader

const cssLoader = {
  test: /\.css$/,
};
const cssLoaders = ['css-loader', 'postcss-loader'];

if (isProduction) {
  cssLoader.loader = ExtractTextPlugin.extract('style-loader', cssLoaders);
} else {
  cssLoader.loaders = ['style-loader'].concat(cssLoaders);
}

config.module.loaders.push(cssLoader);

// PostCSS

const postcssPlugins = [autoprefixer];

if (isProduction) {
  postcssPlugins.push(cssnano);
}

config.postcss = postcssPlugins;

// Plugins

if (isProduction) {
  config.plugins.push(
    new ExtractTextPlugin('[name]-[hash].css')
  );

  config.plugins.push(
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false,
        screw_ie8: true,
      },
    })
  );

  config.plugins.push(
    new webpack.optimize.OccurenceOrderPlugin()
  );

  config.plugins.push(
    new CompressionPlugin()
  );

  config.plugins.push(
    new StatsPlugin('manifest.json', {
      chunkModules: false,
      source: false,
      chunks: false,
      modules: false,
      assets: true,
    })
  );
} else {
  config.plugins.push(
    new webpack.NoErrorsPlugin()
  );

  config.plugins.push(
    new webpack.HotModuleReplacementPlugin()
  );
}

// Development server

config.devServer = {
  colors: true,
  compress: false,
  host: '0.0.0.0',
  port: 3000,
  inline: true,
  historyApiFallback: true,
};

module.exports = config;
<commit_msg>Rewrite loaders for `.css` and `.pcss`<commit_after>const path = require('path');
const webpack = require('webpack');
const HtmlPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const autoprefixer = require('autoprefixer');

// Environment

const isProduction = process.env.NODE_ENV === 'production';

// Paths

const src = path.join(__dirname, 'src');
const dist = path.join(__dirname, 'dist');

// Base configuration

const config = {
  entry: path.join(src, 'index.js'),

  output: {
    path: dist,
    publicPath: '/',
  },

  module: {
    loaders: [
      {
        test: /\.jss?$/,
        exclude: /node_modules/,
        loader: 'babel',
      },
      {
        test: /\.json$/,
        loader: 'json',
      },
    ],
  },

  plugins: [
    new webpack.EnvironmentPlugin(['NODE_ENV']),
    new HtmlPlugin({
      template: path.join(src, 'index.ejs'),
      inject: false,
      filename: 'index.html',
    }),
    new webpack.ProvidePlugin({
      fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
    }),
    new webpack.DefinePlugin({
      __DEV__: !isProduction,
    }),
  ],

  resolve: {
    extensions: ['', '.js', '.jss'],
  },
};

// Output configuration

config.output.filename = isProduction ? '[name]-[hash].js' : '[name].js';

// Development tools

config.devtool = isProduction ? 'source-map' : 'eval';

if (!isProduction) {
  config.output.pathinfo = true;
}

// CSS loader

const cssLoader = {
  // NOTE: process external `.css` files.
  test: /\.css$/,
};
const cssLoaders = [
  `css-loader?${JSON.stringify({
    // NOTE: don't need source maps on production. Error don't handles in
    //       styles.
    sourceMap: !isProduction,
    // NOTE: use shorter style name in production, and more informative in
    //       development for debug purposes.
    localIdentName: isProduction
      ? '[hash:base64:4]'
      : '[name]__[local]___[hash:base64:3]',
    // NOTE: minimize result code for production (`css-loader` uses `cssnano`).
    minimize: isProduction,
  })}`,
  // NOTE: use `defaults` pack of plugins for processing external styles.
  'postcss-loader',
];

if (isProduction) {
  // NOTE: extract styles to external file for production build.
  cssLoader.loader = ExtractTextPlugin.extract('style-loader', cssLoaders);
} else {
  cssLoader.loaders = ['style-loader'].concat(cssLoaders);
}

config.module.loaders.push(cssLoader);

// PostCSS loader

const pcssLoader = {
  // NOTE: use `.pcss` extension for PostCSS code.
  test: /\.pcss$/,
};
const pcssLoaders = [
  `css-loader?${JSON.stringify({
    // NOTE: don't need source maps on production. Error don't handles in
    //       styles.
    sourceMap: !isProduction,
    // NOTE: use CSS Modules.
    modules: true,
    // NOTE: use shorter style name in production, and more informative in
    //       development for debug purposes.
    // NOTE: `camelCase` option used for export camel cased names to JS.
    localIdentName: isProduction
      ? '[hash:base64:4]:camelCase'
      : '[name]__[local]___[hash:base64:3]:camelCase',
    // NOTE: minimize result code for production (`css-loader` uses `cssnano`).
    minimize: isProduction,
  })}`,
  // NOTE: use `modules` pack for processing internal CSS modules files.
  'postcss-loader?pack=modules',
];

if (isProduction) {
  // NOTE: extract styles to external file for production build.
  pcssLoader.loader = ExtractTextPlugin.extract('style-loader', pcssLoaders);
} else {
  pcssLoader.loaders = ['style-loader'].concat(pcssLoaders);
}

config.module.loaders.push(pcssLoader);

// PostCSS

config.postcss = function postcssPacks() {
  return {
    // NOTE: PostCSS plugins for processing external CSS dependencies.
    defaults: [autoprefixer],
    // NOTE: PostCSS plugins for processing internal CSS modules.
    modules: [autoprefixer],
  };
};

// Plugins

if (isProduction) {
  config.plugins.push(
    new ExtractTextPlugin('[name]-[hash].css')
  );

  config.plugins.push(
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false,
        screw_ie8: true,
      },
    })
  );

  config.plugins.push(
    new webpack.optimize.OccurenceOrderPlugin()
  );

  config.plugins.push(
    new CompressionPlugin()
  );

  config.plugins.push(
    new StatsPlugin('manifest.json', {
      chunkModules: false,
      source: false,
      chunks: false,
      modules: false,
      assets: true,
    })
  );
} else {
  config.plugins.push(
    new webpack.NoErrorsPlugin()
  );

  config.plugins.push(
    new webpack.HotModuleReplacementPlugin()
  );
}

// Development server

config.devServer = {
  colors: true,
  compress: false,
  host: '0.0.0.0',
  port: 3000,
  inline: true,
  historyApiFallback: true,
};

module.exports = config;
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');

const configuration = {
  entry: ['./src/bundle.js'],
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'craft-ai.js'
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
        'CRAFT_TOKEN': undefined,
        'CRAFT_URL': undefined
      }
    })
  ],
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        options: {
          cacheDirectory: true,
          presets: [
            ['env', {
              targets: {
                browsers: 'last 2 versions, > 5%'
              },
              modules: false,
              useBuiltIns: true
            }]
          ]
        }
      }
    ]
  }
};

if (process.env.NODE_ENV === 'production') {
  configuration.entry.unshift(require.resolve('babel-polyfill'), require.resolve('whatwg-fetch'));
  configuration.output.filename = 'craft-ai.min.js';
}

module.exports = configuration;
<commit_msg>Update webpack config<commit_after>const path = require('path');
const webpack = require('webpack');

const configuration = {
  entry: ['./src/bundle.js'],
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'craft-ai.js'
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
        'CRAFT_TOKEN': undefined,
        'CRAFT_URL': undefined
      }
    })
  ],
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
            cacheDirectory: true
          }
        }
      }
    ]
  }
};

if (process.env.NODE_ENV === 'production') {
  configuration.entry.unshift(require.resolve('whatwg-fetch'));
  configuration.output.filename = 'craft-ai.min.js';
}

module.exports = configuration;
<|endoftext|>


<commit_before>module.exports = {
    entry: [
        './src/app.jsx'
    ],
    module: {
        rules: [
            {
                test: /\.jsx$/,
                exclude: /(node_modules|bower_components)/,
                // use: {
                //     loader: 'babel-loader',
                // }
                loader: "babel-loader",
                query: {
                    presets: ['react']
                }
            },
            {
                test: /\.css$/,
                use: [ 'style-loader', 'css-loader' ]
            },
        ]
    },
    output: {
        filename: 'bundle.js',
        path: __dirname + '/dist'
    }
}<commit_msg>hack from github to get modules and __dirname working when jsx is bundled<commit_after>module.exports = {
    entry: [
        './src/app.jsx'
    ],
    module: {
        rules: [
            {
                test: /\.jsx$/,
                exclude: /(node_modules|bower_components)/,
                // use: {
                //     loader: 'babel-loader',
                // }
                loader: "babel-loader",
                query: {
                    presets: ['react']
                }
            },
            {
                test: /\.css$/,
                use: [ 'style-loader', 'css-loader' ]
            },
        ]
    },
    /* webpack hack to get private ig working in image.jsx */
    target: 'node',
    node: {
        __dirname: false,
        __filename: false,
    },
    output: {
        filename: 'bundle.js',
        path: __dirname + '/dist'
    }
}<|endoftext|>


<commit_before>// This lets us require files with JSX/ES6 in them
require('babel-core/register')

var path = require('path')
var fs = require('fs')
var React = require('react')
var ReactDOMServer = require('react-dom/server')
var getConfig = require('hjs-webpack')
var sizeOf = require('image-size')
var merge = require('lodash.merge')
var Layout = require('./src/components/Layout').default
var Index = require('./src/pages/index').default
var data = require('./src/data')
var ogImage = sizeOf('./build/media/og-image.png')
var pkg = require('./package.json')

var hjsConfig = getConfig({
  in: 'src/app.js',
  out: 'build',
  clearBeforeBuild: '!(css|fonts|media|favicon.ico|apple-touch-icon.png|AUTH)',
  html: function (context) {
    // Use React's `renderToString` method to return an HTML string from our
    // components (dynamic values can be passed into `createElement` too)
    var renderPage = function (page) {
      var pageHtmlString = page ? ReactDOMServer.renderToString(React.createElement(Layout, {}, React.createElement(page))) : ''
      var title = `${data.name.en}${data.titleSeparator}${data.title.en} • ${data.name.ja}${data.titleSeparator}${data.title.ja}`

      console.log(title)

      return context.defaultTemplate({
        html: `<div id="js-root" class="no-js"><div>${pageHtmlString}</div></div>`,
        title: title,
        lang: 'en',
        publicPath: '',
        metaTags: {
          description: data.description,
          'og:url': data.url,
          'og:title': data.og.title || data.title,
          'og:description': data.og.description || data.description,
          'og:site_name': data.distributor.name,
          'article:author': data.author.name,
          'twitter:creator': '@' + data.author.twitter,
          'twitter:site': '@' + data.distributor.twitter,
          'twitter:card': 'summary_large_image',
          'twitter:image': data.url + '/media/og-image.png?' + pkg.version,
          'og:image': data.url + '/media/og-image.png',
          'og:image:type': 'image/png',
          'og:image:width': ogImage.width,
          'og:image:height': ogImage.height,
          // 'apple-mobile-web-app-title': data.name
        }
      })
    }

    return {
      '200.html': renderPage(),
      'index.html': renderPage(Index)
      // , 'contributing.html': renderPage(Contributing)
    }
  }
})

// Only needed if custom contributing page is used
// var additionalLoaders = [
//   {
//      test: /\.md$/,
//      loader: 'html!markdown'
//   }
// ]
// hjsConfig.module.loaders.push(additionalLoaders)

// Having hmre present in the .babelrc will break with the `babel-core/register` above
// so wait until that is done and then add it here via the loader query
if (process.env.NODE_ENV === 'development') {
  const babelrc = JSON.parse(fs.readFileSync('./.babelrc'))
  babelrc.env = {development: {presets: ['react-hmre']}}
  hjsConfig.module.loaders[0].query = babelrc
}

module.exports = hjsConfig
<commit_msg>Removes console.log in title<commit_after>// This lets us require files with JSX/ES6 in them
require('babel-core/register')

var path = require('path')
var fs = require('fs')
var React = require('react')
var ReactDOMServer = require('react-dom/server')
var getConfig = require('hjs-webpack')
var sizeOf = require('image-size')
var merge = require('lodash.merge')
var Layout = require('./src/components/Layout').default
var Index = require('./src/pages/index').default
var data = require('./src/data')
var ogImage = sizeOf('./build/media/og-image.png')
var pkg = require('./package.json')

var hjsConfig = getConfig({
  in: 'src/app.js',
  out: 'build',
  clearBeforeBuild: '!(css|fonts|media|favicon.ico|apple-touch-icon.png|AUTH)',
  html: function (context) {
    // Use React's `renderToString` method to return an HTML string from our
    // components (dynamic values can be passed into `createElement` too)
    var renderPage = function (page) {
      var pageHtmlString = page ? ReactDOMServer.renderToString(React.createElement(Layout, {}, React.createElement(page))) : ''
      var title = `${data.name.en}${data.titleSeparator}${data.title.en} • ${data.name.ja}${data.titleSeparator}${data.title.ja}`

      return context.defaultTemplate({
        html: `<div id="js-root" class="no-js"><div>${pageHtmlString}</div></div>`,
        title: title,
        lang: 'en',
        publicPath: '',
        metaTags: {
          description: data.description,
          'og:url': data.url,
          'og:title': data.og.title || data.title,
          'og:description': data.og.description || data.description,
          'og:site_name': data.distributor.name,
          'article:author': data.author.name,
          'twitter:creator': '@' + data.author.twitter,
          'twitter:site': '@' + data.distributor.twitter,
          'twitter:card': 'summary_large_image',
          'twitter:image': data.url + '/media/og-image.png?' + pkg.version,
          'og:image': data.url + '/media/og-image.png',
          'og:image:type': 'image/png',
          'og:image:width': ogImage.width,
          'og:image:height': ogImage.height,
          // 'apple-mobile-web-app-title': data.name
        }
      })
    }

    return {
      '200.html': renderPage(),
      'index.html': renderPage(Index)
      // , 'contributing.html': renderPage(Contributing)
    }
  }
})

// Only needed if custom contributing page is used
// var additionalLoaders = [
//   {
//      test: /\.md$/,
//      loader: 'html!markdown'
//   }
// ]
// hjsConfig.module.loaders.push(additionalLoaders)

// Having hmre present in the .babelrc will break with the `babel-core/register` above
// so wait until that is done and then add it here via the loader query
if (process.env.NODE_ENV === 'development') {
  const babelrc = JSON.parse(fs.readFileSync('./.babelrc'))
  babelrc.env = {development: {presets: ['react-hmre']}}
  hjsConfig.module.loaders[0].query = babelrc
}

module.exports = hjsConfig
<|endoftext|>