<commit_before>var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
// var CODE = __dirname+'/src';
var TRACEUR_RUNTIME = require('traceur-compiler-loader').runtime;

module.exports = {
  devtool: '#eval-source-map',
  devServer: {
    contentBase: 'public',
    // publicPath: 'public'
  },
  debug: true,
  cache: false,

  context: __dirname,
  publicPath: 'public',

  entry: {
    shared: [
      // 'zone.js',
      // 'zone.js/long-stack-trace-zone.js',
      'rtts_assert/rtts_assert',
      './src/common/shared'
    ],
    // angular2: 'angular2/angular2',
    app: './src/app/app'
  },
  output: {
    path: 'public/__build__',
    filename: '[name].js',
    sourceMapFilename: '[name].js.map',
    chunkFilename: '[id].chunk.js'
    // publicPath: 'http://mycdn.com/'
  },

  stats: {
    colors: true,
    reasons: true
  },

  resolve: {
    extensions: [
      '',
      '.js',
      '.es6',
      '.es7',
      '.ts',
      '.json',
      '.webpack.js',
      '.web.js'
    ],
    alias: {
      // 'angular2$': '/node_modules/angular2/atscript/angular2',
      'app/*': '/app/*',
      'components/*': '/app/components/*.js',
      'decorators/*': '/app/decorators/*.js',
      'services/*': '/app/services/*.js',
      'stores/*': '/app/stores/*.js'
    }
  },

  module: {
    loaders: [
      // Define assert in global
      // { test: require.resolve('angular2/angular2'), loader: "traceur-compiler-loader?" },
      // { test: require.resolve('rtts_assert/rtts_assert'), loader: "imports?window&zone" },
      // Support for *.json files.
      { test: /\.json$/,                    loader: 'json-loader' },
      // Support for CSS (with hot module replacement)
      { test: /\.css$/,                     loader: 'style-loader!css-loader' },
      // Copy all assets in to asset folder (use hash filename)
      { test: /\.(png|jpg|gif|woff|eot|ttf|svg)$/,      loader: 'file-loader?name=assets/[hash].[ext]' },
      // Load all *.jade as templates
      { test: /(?!\.html)\.jade$/,          loader: 'jade-loader' },
      // Copy all .html.jade as static html files (keep filename)
      { test: /index[a-z-]*\.html\.jade$/,  loader: 'file-loader?name=[path][name]&context=./src!jade-html-loader' },
      // Copy all .html as static file (keep filename)
      { test: /index[a-z-]*\.html$/,        loader: 'file-loader?name=[path][name].html&context=./src' },
      // Support for .es6 files.
      { test: /\.es6/,                      loader: 'babel-loader' },
      // Support for .ts files.
      { test: /\.ts$/,                      loader: 'typescript-loader' },
      // Support for .es7 files.
      { test: /\.es7/,                      loader: ['traceur-compiler-loader'].concat([
                                              // 'inputSourceMap=true',
                                              // 'imports=true',
                                              'runtime=false',
                                              'sourceMaps=true',
                                              'moduleName=true',
                                              'modules=commonjs',
                                              'experimental',
                                              'types',
                                              'annotations',
                                              'memberVariables'
                                              // 'typeAssertionModule="rtts_assert"'
                                            ].join('&')).join('?')
      }
    ],
    noParse: [
      new RegExp(TRACEUR_RUNTIME),
      /rtts_assert\/src\/rtts_assert/,
      /\/zone\.js$/
    ]
  },

  plugins: [
    // new webpack.optimize.DedupePlugin(),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'shared',

      // filename: "vendor.js"
      // (Give the chunk a different name)

      minChunks: Infinity,
      // (with more entries, this ensures that no other module
      //  goes into the vendor chunk)
    }),
    // new webpack.optimize.UglifyJsPlugin({
    //   compress: {
    //     warnings: false
    //   }
    // })
    new webpack.BannerPlugin(getBanner(), {raw: true})
  ]

};

function getBanner() {
  return '// Angular2 Webpack Seed by @gdi2290 \n';
}

function isDirectory(dir) {
  return fs.lstatSync(dir).isDirectory();
}

<commit_msg>refactor: wip alias, use modulesDirectories for now<commit_after>var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
// var CODE = __dirname+'/src';
var TRACEUR_RUNTIME = require('traceur-compiler-loader').runtime;

module.exports = {
  devtool: '#eval-source-map',
  devServer: {
    contentBase: 'public',
    // publicPath: 'public'
  },
  debug: true,
  cache: false,

  context: __dirname,
  publicPath: 'public',

  entry: {
    shared: [
      // 'zone.js',
      // 'zone.js/long-stack-trace-zone.js',
      'rtts_assert/rtts_assert',
      './src/common/shared'
    ],
    // angular2: 'angular2/angular2',
    app: './src/app/bootstrap'
  },
  output: {
    path: 'public/__build__',
    filename: '[name].js',
    sourceMapFilename: '[name].js.map',
    chunkFilename: '[id].chunk.js'
    // publicPath: 'http://mycdn.com/'
  },

  stats: {
    colors: true,
    reasons: true
  },

  resolve: {
    root: __dirname,
    extensions: [
      '',
      '.js',
      '.es6',
      '.es7',
      '.ts',
      '.json',
      '.webpack.js',
      '.web.js'
    ],
    // Todo: learn more about aslias
    // alias: {
      // 'angular2$': '/node_modules/angular2/atscript/angular2',
      // 'app/*': '/app/*'
      // 'components$': '/src/app/components/'
      // 'decorators/*': '/app/decorators/*.js',
      // 'services/*': '/app/services/*.js',
      // 'stores/*': '/app/stores/*.js'
    // },
    modulesDirectories: [
      'web_modules',
      'node_modules',
      'src/app' // hard coded for now until I figure out alias
    ]
  },

  module: {
    loaders: [
      // Define assert in global
      // { test: require.resolve('angular2/angular2'), loader: "traceur-compiler-loader?" },
      // { test: require.resolve('rtts_assert/rtts_assert'), loader: "imports?window&zone" },
      // Support for *.json files.
      { test: /\.json$/,                    loader: 'json-loader' },
      // Support for CSS (with hot module replacement)
      { test: /\.css$/,                     loader: 'style-loader!css-loader' },
      // Copy all assets in to asset folder (use hash filename)
      { test: /\.(png|jpg|gif|woff|eot|ttf|svg)$/,      loader: 'file-loader?name=assets/[hash].[ext]' },
      // Load all *.jade as templates
      { test: /(?!\.html)\.jade$/,          loader: 'jade-loader' },
      // Copy all .html.jade as static html files (keep filename)
      { test: /index[a-z-]*\.html\.jade$/,  loader: 'file-loader?name=[path][name]&context=./src!jade-html-loader' },
      // Copy all .html as static file (keep filename)
      { test: /index[a-z-]*\.html$/,        loader: 'file-loader?name=[path][name].html&context=./src' },
      // Support for .es6 files.
      { test: /\.es6/,                      loader: 'babel-loader' },
      // Support for .ts files.
      { test: /\.ts$/,                      loader: 'typescript-loader' },
      // Support for .es7 files.
      { test: /\.es7/,                      loader: ['traceur-compiler-loader'].concat([
                                              // 'inputSourceMap=true',
                                              // 'imports=true',
                                              'runtime=false',
                                              'sourceMaps=true',
                                              'moduleName=true',
                                              'modules=commonjs',
                                              'experimental',
                                              'types',
                                              'annotations',
                                              'memberVariables'
                                              // 'typeAssertionModule="rtts_assert"'
                                            ].join('&')).join('?')
      }
    ],
    noParse: [
      new RegExp(TRACEUR_RUNTIME),
      /rtts_assert\/src\/rtts_assert/,
      /\/zone\.js$/
    ]
  },

  plugins: [
    // new webpack.optimize.DedupePlugin(),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'shared',

      // filename: "vendor.js"
      // (Give the chunk a different name)

      minChunks: Infinity,
      // (with more entries, this ensures that no other module
      //  goes into the vendor chunk)
    }),
    // new webpack.optimize.UglifyJsPlugin({
    //   compress: {
    //     warnings: false
    //   }
    // })
    new webpack.BannerPlugin(getBanner(), {raw: true})
  ]

};

function getBanner() {
  return '// Angular2 Webpack Seed by @gdi2290 \n';
}

function isDirectory(dir) {
  return fs.lstatSync(dir).isDirectory();
}

<|endoftext|>


<commit_before>var _ = require('underscore');
var path = require('path');
var pkg = require('./package');

var webpackAlias = pkg.webpackAlias || {};

try {
  webpackAlias = require('./webpack.alias');
} catch (e) { }

function getExternals() {
  var deps = _.keys(pkg.peerDependencies);
  var externals = _.object(deps, deps);

  return _.reduce(_.pairs(webpackAlias), function (exts, pair) {
    if (_.has(externals, pair[1])) {
      exts[pair[0]] = pair[1];
    }
    return exts;
  }, externals);
}

module.exports = {
  entry: path.resolve('./js/index.js'),
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'projection-grid.js',
    library: 'projection-grid',
    libraryTarget: 'umd',
    umdNamedDefine: false,
    devtoolModuleFilenameTemplate: function (info) {
      if (path.isAbsolute(info.absoluteResourcePath)) {
        return 'webpack-src:///projection-grid-example/' + path.relative('.', info.absoluteResourcePath);
      }
      return info.absoluteResourcePath;
    },
  },
  module: {
    loaders: [
      // jade
      { test: /\.jade$/, loader: 'jade-loader' },
      // jade-end
      // es2015
      { test: /\.js$/, exclude: /\bnode_modules\b/, loader: 'babel-loader' },
      // es2015-end
      { test: /\.less$/, loader: 'style!css!less' },
    ],
  },
  babel: { presets: ['es2015'] },
  externals: [getExternals()],
  resolve: { alias: webpackAlias },
  devtool: 'source-map',
};
<commit_msg>remove '-example' & inline src map<commit_after>var _ = require('underscore');
var path = require('path');
var pkg = require('./package');

var webpackAlias = pkg.webpackAlias || {};

try {
  webpackAlias = require('./webpack.alias');
} catch (e) { }

function getExternals() {
  var deps = _.keys(pkg.peerDependencies);
  var externals = _.object(deps, deps);

  return _.reduce(_.pairs(webpackAlias), function (exts, pair) {
    if (_.has(externals, pair[1])) {
      exts[pair[0]] = pair[1];
    }
    return exts;
  }, externals);
}

module.exports = {
  entry: path.resolve('./js/index.js'),
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'projection-grid.js',
    library: 'projection-grid',
    libraryTarget: 'umd',
    umdNamedDefine: false,
    devtoolModuleFilenameTemplate: function (info) {
      if (path.isAbsolute(info.absoluteResourcePath)) {
        // return 'webpack-src:///projection-grid/' + path.posix.relative('.', info.absoluteResourcePath);
        return 'webpack-src:///projection-grid/' + path.relative('.', info.absoluteResourcePath).replace(new RegExp('\\' + path.sep), '/');
      }
      return info.absoluteResourcePath;
    },
  },
  module: {
    loaders: [
      // jade
      { test: /\.jade$/, loader: 'jade-loader' },
      // jade-end
      // es2015
      { test: /\.js$/, exclude: /\bnode_modules\b/, loader: 'babel-loader' },
      // es2015-end
      { test: /\.less$/, loader: 'style!css!less' },
    ],
  },
  babel: { presets: ['es2015'] },
  externals: [getExternals()],
  resolve: { alias: webpackAlias },
  devtool: 'inline-source-map',
};

<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

// PostCSS plugins
var cssnext = require('postcss-cssnext');
var postcssFocus = require('postcss-focus');
var postcssReporter = require('postcss-reporter');

module.exports = {
    target: 'web',
    stats: false,
    progress: true,
    entry: {
        main: ['./assets/webpack-public-path', './assets/main'],
        'main-critical': ['./assets/webpack-public-path', './assets/main/index-critical']
    },
    output: {
        path: path.join(__dirname, 'web/wp-content/themes/wordpress-boilerplate/assets/scripts'),
        publicPath: '/wp-content/themes/wordpress-boilerplate/assets/scripts/',
        filename: '[name].js', // append ?[hash] to fix entry chunks not updated correctly
        chunkFilename: '[name].[chunkhash].js'
    },
    module: {
        loaders: [
            {
                test: /\.less$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract(
                    'style',
                    'css!postcss!less'
                )
            },
            {
                test: /\.css$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract(
                    'style',
                    'css!postcss'
                )
            },
            {
                test: /\.less$/,
                include: /node_modules/,
                loaders: ['style', 'css', 'less']
            },
            {
                test: /\.css$/,
                include: /node_modules/,
                loaders: ['style', 'css']
            },

            {
                test: /\.(gif|png|jpe?g|svg)(\?.+)?$/,
                loaders: [
                    'file?name=static/[hash].[ext]',
                    'image-webpack?{progressive:true, optimizationLevel: 7, interlaced: false, pngquant:{quality: "65-90", speed: 4}}'
                ]
            },

            {
                test: /\.(eot|ttf|woff|woff2)(\?.+)?$/,
                loaders: ['file?name=static/[hash].[ext]']
            },

            {
                test: /\.(swf|xap)$/,
                loaders: ['file?name=static/[hash].[ext]']
            },

            // required for modernizr, see https://github.com/webpack/webpack/issues/512
            {
                test: /modernizr\.js$/,
                loaders: ['imports?this=>window', 'exports?window.Modernizr']
            }
        ]
    },
    postcss: [
        postcssFocus(),
        cssnext(),
        postcssReporter({
            clearMessages: true
        })
    ],
    plugins: [
        new webpack.ProvidePlugin({
            // Automtically detect jQuery and $ as free var in modules
            // and inject the jquery library
            // This is required by many jquery plugins
            jQuery: 'jquery',
            $: 'jquery'
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('production')
            }
        }),
        // OccurrenceOrderPlugin is needed for long-term caching to work properly.
        // See http://mxs.is/googmv
        new webpack.optimize.OccurrenceOrderPlugin(true),
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        }),
        new webpack.NoErrorsPlugin(),

        new ExtractTextPlugin('[name].css')
    ]
};
<commit_msg>Show webpack stats<commit_after>var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

// PostCSS plugins
var cssnext = require('postcss-cssnext');
var postcssFocus = require('postcss-focus');
var postcssReporter = require('postcss-reporter');

module.exports = {
    target: 'web',
    progress: true,
    entry: {
        main: ['./assets/webpack-public-path', './assets/main'],
        'main-critical': ['./assets/webpack-public-path', './assets/main/index-critical']
    },
    output: {
        path: path.join(__dirname, 'web/wp-content/themes/wordpress-boilerplate/assets/scripts'),
        publicPath: '/wp-content/themes/wordpress-boilerplate/assets/scripts/',
        filename: '[name].js', // append ?[hash] to fix entry chunks not updated correctly
        chunkFilename: '[name].[chunkhash].js'
    },
    module: {
        loaders: [
            {
                test: /\.less$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract(
                    'style',
                    'css!postcss!less'
                )
            },
            {
                test: /\.css$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract(
                    'style',
                    'css!postcss'
                )
            },
            {
                test: /\.less$/,
                include: /node_modules/,
                loaders: ['style', 'css', 'less']
            },
            {
                test: /\.css$/,
                include: /node_modules/,
                loaders: ['style', 'css']
            },

            {
                test: /\.(gif|png|jpe?g|svg)(\?.+)?$/,
                loaders: [
                    'file?name=static/[hash].[ext]',
                    'image-webpack?{progressive:true, optimizationLevel: 7, interlaced: false, pngquant:{quality: "65-90", speed: 4}}'
                ]
            },

            {
                test: /\.(eot|ttf|woff|woff2)(\?.+)?$/,
                loaders: ['file?name=static/[hash].[ext]']
            },

            {
                test: /\.(swf|xap)$/,
                loaders: ['file?name=static/[hash].[ext]']
            },

            // required for modernizr, see https://github.com/webpack/webpack/issues/512
            {
                test: /modernizr\.js$/,
                loaders: ['imports?this=>window', 'exports?window.Modernizr']
            }
        ]
    },
    postcss: [
        postcssFocus(),
        cssnext(),
        postcssReporter({
            clearMessages: true
        })
    ],
    plugins: [
        new webpack.ProvidePlugin({
            // Automtically detect jQuery and $ as free var in modules
            // and inject the jquery library
            // This is required by many jquery plugins
            jQuery: 'jquery',
            $: 'jquery'
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('production')
            }
        }),
        // OccurrenceOrderPlugin is needed for long-term caching to work properly.
        // See http://mxs.is/googmv
        new webpack.optimize.OccurrenceOrderPlugin(true),
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        }),
        new webpack.NoErrorsPlugin(),

        new ExtractTextPlugin('[name].css')
    ]
};
<|endoftext|>


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

/*
 * Webpack Plugins
 */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');

// take debug mode from the environment
const debug = (process.env.NODE_ENV !== 'prod');

// Development asset host (webpack dev server)
const publicHost = debug ? 'http://localhost:2992' : '';

const rootAssetPath = './assets/';

module.exports = {
  // configuration
  context: __dirname,
  entry: {
    main_js: './assets/js/index',
    app_js: './assets/js/app',
    app_css: [
      './node_modules/font-awesome/css/font-awesome.css',
      './node_modules/bootstrap/dist/css/bootstrap.css',
      './assets/css/style.css'
    ]
  },
  output: {
    path: __dirname + '/annotator/static',
    publicPath: publicHost + '/static/',
    filename: '[name].[hash].js',
    chunkFilename: '[id].[hash].js'
  },
  resolve: {
    extensions: ['.js', '.jsx', '.css']
  },
  devServer: {
    headers: {'Access-Control-Allow-Origin': '*'},
    publicPath: '/static/'
  },
  module: {
    loaders: [
      { test: /\.html$/, loader: 'raw-loader' },
      { test: /\.less$/, loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader!less-loader'}) },
      { test: /\.css$/, loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader'}) },
      { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' },
      { test: /\.(ttf|eot|svg|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader?context=' + rootAssetPath + '&name=[path][name].[hash].[ext]' },
      { test: /\.(png|jpe?g|gif)(\?\S*)?$/, loader: 'url-loader?limit=100000' },
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['es2015'], cacheDirectory: true, compact: true } },
    ]
  },
  plugins: [
    new ExtractTextPlugin('[name].[hash].css'),
    new webpack.ProvidePlugin({ $: 'jquery',
                                jQuery: 'jquery' }),
    new ManifestRevisionPlugin(__dirname + '/annotator/webpack/manifest.json', {
      rootAssetPath,
      ignorePaths: ['/js', '/css']
    }),
  ].concat(debug ? [] : [
    //new webpack.optimize.OccurrenceOrderPlugin(),
    //new webpack.HotModuleReplacementPlugin(),
  ])
};
<commit_msg>webpack.config.js: track changes in cookiecutter-flask<commit_after>const webpack = require('webpack');

/*
 * Webpack Plugins
 */
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestRevisionPlugin = require('manifest-revision-webpack-plugin');

// take debug mode from the environment
const debug = (process.env.NODE_ENV !== 'prod');

// Development asset host (webpack dev server)
const publicHost = debug ? 'http://localhost:2992' : '';

const rootAssetPath = './assets/';

module.exports = {
  // configuration
  context: __dirname,
  entry: {
    main_js: './assets/js/index',
    app_js: './assets/js/app',
    app_css: [
      './node_modules/font-awesome/css/font-awesome.css',
      './node_modules/bootstrap/dist/css/bootstrap.css',
      './assets/css/style.css'
    ]
  },
  output: {
    path: __dirname + '/annotator/static',
    publicPath: publicHost + '/static/',
    filename: '[name].[hash].js',
    chunkFilename: '[id].[hash].js'
  },
  resolve: {
    extensions: ['.js', '.jsx', '.css']
  },
  devtool: debug ? '#inline-sourcemap' : false,
  devServer: {
    headers: { 'Access-Control-Allow-Origin': '*' }
  },
  module: {
    loaders: [
      { test: /\.html$/, loader: 'raw-loader' },
      { test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!less-loader' }) },
      { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
      { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' },
      { test: /\.(ttf|eot|svg|png|jpe?g|gif|ico)(\?.*)?$/i,
        loader: 'file-loader?context=' + rootAssetPath + '&name=[path][name].[hash].[ext]' },
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['es2015'], cacheDirectory: true } },
    ]
  },
  plugins: [
    new ExtractTextPlugin('[name].[hash].css'),
    new webpack.ProvidePlugin({ $: 'jquery',
                                jQuery: 'jquery' }),
    new ManifestRevisionPlugin(__dirname + '/annotator/webpack/manifest.json', {
      rootAssetPath,
      ignorePaths: ['/js', '/css']
    }),
  ].concat(debug ? [] : [
    // production webpack plugins go here
  ])
};
<|endoftext|>


<commit_before>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const webpack = require("webpack");

let og_image_url = process.env.RIOT_OG_IMAGE_URL;
if (!og_image_url) og_image_url = 'https://riot.im/app/themes/riot/img/logos/opengraph.png';

module.exports = (env, argv) => {
    if (process.env.CI_PACKAGE) {
        // Don't run minification for CI builds (this is only set for runs on develop)
        argv.mode = "development";
    }

    const development = {};
    if (argv.mode !== "production") {
        // This makes the sourcemaps human readable for developers. We use eval-source-map
        // because the plain source-map devtool ruins the alignment.
        development['devtool'] = 'eval-source-map';
    } else {
        development['devtool'] = 'nosources-source-map';
    }

    // Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early so we
    // don't have to call them over and over. We also resolve to the package.json instead of the src
    // directory so we don't have to rely on a index.js or similar file existing.
    const reactSdkSrcDir = path.resolve(require.resolve("matrix-react-sdk/package.json"), '..', 'src');
    const jsSdkSrcDir = path.resolve(require.resolve("matrix-js-sdk/package.json"), '..', 'src');

    return {
        ...development,

        entry: {
            "bundle": "./src/vector/index.ts",
            "indexeddb-worker": "./src/vector/indexeddb-worker.js",
            "mobileguide": "./src/vector/mobile_guide/index.js",
            "jitsi": "./src/vector/jitsi/index.ts",
            "usercontent": "./node_modules/matrix-react-sdk/src/usercontent/index.js",

            // CSS themes
            "theme-light": "./node_modules/matrix-react-sdk/res/themes/light/css/light.scss",
            "theme-dark": "./node_modules/matrix-react-sdk/res/themes/dark/css/dark.scss",
            "theme-light-custom": "./node_modules/matrix-react-sdk/res/themes/light-custom/css/light-custom.scss",
            "theme-dark-custom": "./node_modules/matrix-react-sdk/res/themes/dark-custom/css/dark-custom.scss",
        },

        optimization: {
            // Put all of our CSS into one useful place - this is needed for MiniCssExtractPlugin.
            // Previously we used a different extraction plugin that did this magic for us, but
            // now we need to consider that the CSS needs to be bundled up together.
            splitChunks: {
                cacheGroups: {
                    styles: {
                        name: 'styles',
                        test: /\.css$/,
                        enforce: true,
                        // Do not add `chunks: 'all'` here because you'll break the app entry point.
                    },
                    default: {
                        reuseExistingChunk: true,
                    },
                },
            },

            // This fixes duplicate files showing up in chrome with sourcemaps enabled.
            // See https://github.com/webpack/webpack/issues/7128 for more info.
            namedModules: false,

            // Minification is normally enabled by default for webpack in production mode, but
            // we use a CSS optimizer too and need to manage it ourselves.
            minimize: argv.mode === 'production',
            minimizer: argv.mode === 'production' ? [new TerserPlugin({}), new OptimizeCSSAssetsPlugin({})] : [],
        },

        resolve: {
            // We define an alternative import path so we can safely use src/ across the react-sdk
            // and js-sdk. We already import from src/ where possible to ensure our source maps are
            // extremely accurate (and because we're capable of compiling the layers manually rather
            // than relying on partially-mangled output from babel), though we do need to fix the
            // package level import (stuff like `import {Thing} from "matrix-js-sdk"` for example).
            // We can't use the aliasing down below to point at src/ because that'll fail to resolve
            // the package.json for the dependency. Instead, we rely on the package.json of each
            // layer to have our custom alternate fields to load things in the right order. These are
            // the defaults of webpack prepended with `matrix_src_`.
            mainFields: ['matrix_src_browser', 'matrix_src_main', 'browser', 'main'],
            aliasFields: ['matrix_src_browser', 'browser'],

            // We need to specify that TS can be resolved without an extension
            extensions: ['.js', '.json', '.ts', '.tsx'],
            alias: {
                // alias any requires to the react module to the one in our path,
                // otherwise we tend to get the react source included twice when
                // using `npm link` / `yarn link`.
                "react": path.resolve(__dirname, 'node_modules/react'),
                "react-dom": path.resolve(__dirname, 'node_modules/react-dom'),

                // same goes for js-sdk - we don't need two copies.
                "matrix-js-sdk": path.resolve(__dirname, 'node_modules/matrix-js-sdk'),
                // and prop-types and sanitize-html
                "prop-types": path.resolve(__dirname, 'node_modules/prop-types'),
                "sanitize-html": path.resolve(__dirname, 'node_modules/sanitize-html'),

                // Define a variable so the i18n stuff can load
                "$webapp": path.resolve(__dirname, 'webapp'),
            },
        },

        module: {
            noParse: [
                // for cross platform compatibility use [\\\/] as the path separator
                // this ensures that the regex trips on both Windows and *nix

                // don't parse the languages within highlight.js. They cause stack
                // overflows (https://github.com/webpack/webpack/issues/1721), and
                // there is no need for webpack to parse them - they can just be
                // included as-is.
                /highlight\.js[\\\/]lib[\\\/]languages/,

                // olm takes ages for webpack to process, and it's already heavily
                // optimised, so there is little to gain by us uglifying it.
                /olm[\\\/](javascript[\\\/])?olm\.js$/,
            ],
            rules: [
                {
                    test: /\.(ts|js)x?$/,
                    include: (f) => {
                        // our own source needs babel-ing
                        if (f.startsWith(path.resolve(__dirname, 'src'))) return true;

                        // we use the original source files of react-sdk and js-sdk, so we need to
                        // run them through babel. Because the path tested is the resolved, absolute
                        // path, these could be anywhere thanks to yarn link. We must also not
                        // include node modules inside these modules, so we add 'src'.
                        if (f.startsWith(reactSdkSrcDir)) return true;
                        if (f.startsWith(jsSdkSrcDir)) return true;

                        // but we can't run all of our dependencies through babel (many of them still
                        // use module.exports which breaks if babel injects an 'include' for its
                        // polyfills: probably fixable but babeling all our dependencies is probably
                        // not necessary anyway). So, for anything else, don't babel.
                        return false;
                    },
                    loader: 'babel-loader',
                    options: {
                        cacheDirectory: true
                    }
                },
                {
                    test: /\.css$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        {
                            loader: 'css-loader',
                            options: {
                                importLoaders: 1,
                                sourceMap: true,
                            }
                        },
                        {
                            loader: 'postcss-loader',
                            ident: 'postcss',
                            options: {
                                sourceMap: true,
                                plugins: () => [
                                    // Note that we use significantly fewer plugins on the plain
                                    // CSS parser. If we start to parse plain CSS, we end with all
                                    // kinds of nasty problems (like stylesheets not loading).
                                    //
                                    // You might have noticed that we're also sending regular CSS
                                    // through PostCSS. This looks weird, and in fact is probably
                                    // not what you'd expect, however in order for our CSS build
                                    // to work nicely we have to do this. Because down the line
                                    // our SCSS stylesheets reference plain CSS we have to load
                                    // the plain CSS through PostCSS so it can find it safely. This
                                    // also acts like a babel-for-css by transpiling our (S)CSS
                                    // down/up to the right browser support (prefixes, etc).
                                    // Further, if we don't do this then PostCSS assumes that our
                                    // plain CSS is SCSS and it really doesn't like that, even
                                    // though plain CSS should be compatible. The chunking options
                                    // at the top of this webpack config help group the SCSS and
                                    // plain CSS together for the bundler.

                                    require("postcss-simple-vars")(),
                                    require("postcss-strip-inline-comments")(),
                                    require("postcss-hexrgba")(),

                                    // It's important that this plugin is last otherwise we end
                                    // up with broken CSS.
                                    require('postcss-preset-env')({stage: 3, browsers: 'last 2 versions'}),
                                ],
                                parser: "postcss-scss",
                                "local-plugins": true,
                            },
                        },
                    ]
                },
                {
                    test: /\.scss$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        {
                            loader: 'css-loader',
                            options: {
                                importLoaders: 1,
                                sourceMap: true,
                            }
                        },
                        {
                            loader: 'postcss-loader',
                            ident: 'postcss',
                            options: {
                                sourceMap: true,
                                plugins: () => [
                                    // Note that we use slightly different plugins for SCSS.

                                    require('postcss-import')(),
                                    require("postcss-mixins")(),
                                    require("postcss-simple-vars")(),
                                    require("postcss-extend")(),
                                    require("postcss-nested")(),
                                    require("postcss-easings")(),
                                    require("postcss-strip-inline-comments")(),
                                    require("postcss-hexrgba")(),

                                    // It's important that this plugin is last otherwise we end
                                    // up with broken CSS.
                                    require('postcss-preset-env')({stage: 3, browsers: 'last 2 versions'}),
                                ],
                                parser: "postcss-scss",
                                "local-plugins": true,
                            },
                        },
                    ]
                },
                {
                    test: /\.wasm$/,
                    loader: "file-loader",
                    type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
                    options: {
                        name: '[name].[hash:7].[ext]',
                        outputPath: '.',
                    },
                },
                {
                    // cache-bust languages.json file placed in
                    // riot-web/webapp/i18n during build by copy-res.js
                    test: /\.*languages.json$/,
                    type: "javascript/auto",
                    loader: 'file-loader',
                    options: {
                        name: 'i18n/[name].[hash:7].[ext]',
                    },
                },
                {
                    test: /\.(gif|png|svg|ttf|woff|woff2|xml|ico)$/,
                    // Use a content-based hash in the name so that we can set a long cache
                    // lifetime for assets while still delivering changes quickly.
                    oneOf: [
                        {
                            // Assets referenced in CSS files
                            issuer: /\.(scss|css)$/,
                            loader: 'file-loader',
                            options: {
                                esModule: false,
                                name: '[name].[hash:7].[ext]',
                                outputPath: getImgOutputPath,
                                publicPath: function(url, resourcePath) {
                                    // CSS image usages end up in the `bundles/[hash]` output
                                    // directory, so we adjust the final path to navigate up
                                    // twice.
                                    const outputPath = getImgOutputPath(url, resourcePath);
                                    return toPublicPath(path.join("../..", outputPath));
                                },
                            },
                        },
                        {
                            // Assets referenced in HTML and JS files
                            loader: 'file-loader',
                            options: {
                                esModule: false,
                                name: '[name].[hash:7].[ext]',
                                outputPath: getImgOutputPath,
                                publicPath: function(url, resourcePath) {
                                    const outputPath = getImgOutputPath(url, resourcePath);
                                    return toPublicPath(outputPath);
                                },
                            },
                        },
                    ],
                },
            ]
        },

        plugins: [
            new webpack.DefinePlugin({
                'process.env': {
                    NODE_ENV: JSON.stringify(process.env.NODE_ENV),
                },
            }),

            // This exports our CSS using the splitChunks and loaders above.
            new MiniCssExtractPlugin({
                filename: 'bundles/[hash]/[name].css',
                ignoreOrder: false, // Enable to remove warnings about conflicting order
            }),

            // This is the app's main entry point.
            new HtmlWebpackPlugin({
                template: './src/vector/index.html',

                // we inject the links ourselves via the template, because
                // HtmlWebpackPlugin will screw up our formatting like the names
                // of the themes and which chunks we actually care about.
                inject: false,
                excludeChunks: ['mobileguide', 'usercontent', 'jitsi'],
                minify: argv.mode === 'production',
                vars: {
                    og_image_url: og_image_url,
                },
            }),

            // This is the jitsi widget wrapper (embedded, so isolated stack)
            new HtmlWebpackPlugin({
                template: './src/vector/jitsi/index.html',
                filename: 'jitsi.html',
                minify: argv.mode === 'production',
                chunks: ['jitsi'],
            }),

            // This is the mobile guide's entry point (separate for faster mobile loading)
            new HtmlWebpackPlugin({
                template: './src/vector/mobile_guide/index.html',
                filename: 'mobile_guide/index.html',
                minify: argv.mode === 'production',
                chunks: ['mobileguide'],
            }),

            // These are the static error pages for when the javascript env is *really unsupported*
            new HtmlWebpackPlugin({
                template: './src/vector/static/unable-to-load.html',
                filename: 'static/unable-to-load.html',
                minify: argv.mode === 'production',
                chunks: [],
            }),
            new HtmlWebpackPlugin({
                template: './src/vector/static/incompatible-browser.html',
                filename: 'static/incompatible-browser.html',
                minify: argv.mode === 'production',
                chunks: [],
            }),

            // This is the usercontent sandbox's entry point (separate for iframing)
            new HtmlWebpackPlugin({
                template: './node_modules/matrix-react-sdk/src/usercontent/index.html',
                filename: 'usercontent/index.html',
                minify: argv.mode === 'production',
                chunks: ['usercontent'],
            }),
        ],

        output: {
            path: path.join(__dirname, "webapp"),

            // The generated JS (and CSS, from the extraction plugin) are put in a
            // unique subdirectory for the build. There will only be one such
            // 'bundle' directory in the generated tarball; however, hosting
            // servers can collect 'bundles' from multiple versions into one
            // directory and symlink it into place - this allows users who loaded
            // an older version of the application to continue to access webpack
            // chunks even after the app is redeployed.
            filename: "bundles/[hash]/[name].js",
            chunkFilename: "bundles/[hash]/[name].js",
        },

        // configuration for the webpack-dev-server
        devServer: {
            // serve unwebpacked assets from webapp.
            contentBase: './webapp',

            // Only output errors, warnings, or new compilations.
            // This hides the massive list of modules.
            stats: 'minimal',

            // hot module replacement doesn't work (I think we'd need react-hot-reload?)
            // so webpack-dev-server reloads the page on every update which is quite
            // tedious in Riot since that can take a while.
            hot: false,
            inline: false,
        },
    };
};

/**
 * Merge assets found via CSS and imports into a single tree, while also preserving
 * directories under `res`.
 *
 * @param {string} url The adjusted name of the file, such as `warning.1234567.svg`.
 * @param {string} resourcePath The absolute path to the source file with unmodified name.
 * @return {string} The returned paths will look like `img/warning.1234567.svg`.
 */
function getImgOutputPath(url, resourcePath) {
    const prefix = /^.*[/\\]res[/\\]/;
    const outputDir = path.dirname(resourcePath).replace(prefix, "");
    return path.join(outputDir, path.basename(url));
}

/**
 * Convert path to public path format, which always uses forward slashes, since it will
 * be placed directly into things like CSS files.
 *
 * @param {string} path Some path to a file.
 */
function toPublicPath(path) {
    return path.replace(/\\/g, '/');
}
<commit_msg>element theme webpack config<commit_after>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const webpack = require("webpack");

let og_image_url = process.env.RIOT_OG_IMAGE_URL;
if (!og_image_url) og_image_url = 'https://riot.im/app/themes/riot/img/logos/opengraph.png';

module.exports = (env, argv) => {
    if (process.env.CI_PACKAGE) {
        // Don't run minification for CI builds (this is only set for runs on develop)
        argv.mode = "development";
    }

    const development = {};
    if (argv.mode !== "production") {
        // This makes the sourcemaps human readable for developers. We use eval-source-map
        // because the plain source-map devtool ruins the alignment.
        development['devtool'] = 'eval-source-map';
    } else {
        development['devtool'] = 'nosources-source-map';
    }

    // Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early so we
    // don't have to call them over and over. We also resolve to the package.json instead of the src
    // directory so we don't have to rely on a index.js or similar file existing.
    const reactSdkSrcDir = path.resolve(require.resolve("matrix-react-sdk/package.json"), '..', 'src');
    const jsSdkSrcDir = path.resolve(require.resolve("matrix-js-sdk/package.json"), '..', 'src');

    return {
        ...development,

        entry: {
            "bundle": "./src/vector/index.ts",
            "indexeddb-worker": "./src/vector/indexeddb-worker.js",
            "mobileguide": "./src/vector/mobile_guide/index.js",
            "jitsi": "./src/vector/jitsi/index.ts",
            "usercontent": "./node_modules/matrix-react-sdk/src/usercontent/index.js",

            // CSS themes
            "theme-element": "./node_modules/matrix-react-sdk/res/themes/element/css/element.scss",
            "theme-light": "./node_modules/matrix-react-sdk/res/themes/light/css/light.scss",
            "theme-dark": "./node_modules/matrix-react-sdk/res/themes/dark/css/dark.scss",
            "theme-light-custom": "./node_modules/matrix-react-sdk/res/themes/light-custom/css/light-custom.scss",
            "theme-dark-custom": "./node_modules/matrix-react-sdk/res/themes/dark-custom/css/dark-custom.scss",
        },

        optimization: {
            // Put all of our CSS into one useful place - this is needed for MiniCssExtractPlugin.
            // Previously we used a different extraction plugin that did this magic for us, but
            // now we need to consider that the CSS needs to be bundled up together.
            splitChunks: {
                cacheGroups: {
                    styles: {
                        name: 'styles',
                        test: /\.css$/,
                        enforce: true,
                        // Do not add `chunks: 'all'` here because you'll break the app entry point.
                    },
                    default: {
                        reuseExistingChunk: true,
                    },
                },
            },

            // This fixes duplicate files showing up in chrome with sourcemaps enabled.
            // See https://github.com/webpack/webpack/issues/7128 for more info.
            namedModules: false,

            // Minification is normally enabled by default for webpack in production mode, but
            // we use a CSS optimizer too and need to manage it ourselves.
            minimize: argv.mode === 'production',
            minimizer: argv.mode === 'production' ? [new TerserPlugin({}), new OptimizeCSSAssetsPlugin({})] : [],
        },

        resolve: {
            // We define an alternative import path so we can safely use src/ across the react-sdk
            // and js-sdk. We already import from src/ where possible to ensure our source maps are
            // extremely accurate (and because we're capable of compiling the layers manually rather
            // than relying on partially-mangled output from babel), though we do need to fix the
            // package level import (stuff like `import {Thing} from "matrix-js-sdk"` for example).
            // We can't use the aliasing down below to point at src/ because that'll fail to resolve
            // the package.json for the dependency. Instead, we rely on the package.json of each
            // layer to have our custom alternate fields to load things in the right order. These are
            // the defaults of webpack prepended with `matrix_src_`.
            mainFields: ['matrix_src_browser', 'matrix_src_main', 'browser', 'main'],
            aliasFields: ['matrix_src_browser', 'browser'],

            // We need to specify that TS can be resolved without an extension
            extensions: ['.js', '.json', '.ts', '.tsx'],
            alias: {
                // alias any requires to the react module to the one in our path,
                // otherwise we tend to get the react source included twice when
                // using `npm link` / `yarn link`.
                "react": path.resolve(__dirname, 'node_modules/react'),
                "react-dom": path.resolve(__dirname, 'node_modules/react-dom'),

                // same goes for js-sdk - we don't need two copies.
                "matrix-js-sdk": path.resolve(__dirname, 'node_modules/matrix-js-sdk'),
                // and prop-types and sanitize-html
                "prop-types": path.resolve(__dirname, 'node_modules/prop-types'),
                "sanitize-html": path.resolve(__dirname, 'node_modules/sanitize-html'),

                // Define a variable so the i18n stuff can load
                "$webapp": path.resolve(__dirname, 'webapp'),
            },
        },

        module: {
            noParse: [
                // for cross platform compatibility use [\\\/] as the path separator
                // this ensures that the regex trips on both Windows and *nix

                // don't parse the languages within highlight.js. They cause stack
                // overflows (https://github.com/webpack/webpack/issues/1721), and
                // there is no need for webpack to parse them - they can just be
                // included as-is.
                /highlight\.js[\\\/]lib[\\\/]languages/,

                // olm takes ages for webpack to process, and it's already heavily
                // optimised, so there is little to gain by us uglifying it.
                /olm[\\\/](javascript[\\\/])?olm\.js$/,
            ],
            rules: [
                {
                    test: /\.(ts|js)x?$/,
                    include: (f) => {
                        // our own source needs babel-ing
                        if (f.startsWith(path.resolve(__dirname, 'src'))) return true;

                        // we use the original source files of react-sdk and js-sdk, so we need to
                        // run them through babel. Because the path tested is the resolved, absolute
                        // path, these could be anywhere thanks to yarn link. We must also not
                        // include node modules inside these modules, so we add 'src'.
                        if (f.startsWith(reactSdkSrcDir)) return true;
                        if (f.startsWith(jsSdkSrcDir)) return true;

                        // but we can't run all of our dependencies through babel (many of them still
                        // use module.exports which breaks if babel injects an 'include' for its
                        // polyfills: probably fixable but babeling all our dependencies is probably
                        // not necessary anyway). So, for anything else, don't babel.
                        return false;
                    },
                    loader: 'babel-loader',
                    options: {
                        cacheDirectory: true
                    }
                },
                {
                    test: /\.css$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        {
                            loader: 'css-loader',
                            options: {
                                importLoaders: 1,
                                sourceMap: true,
                            }
                        },
                        {
                            loader: 'postcss-loader',
                            ident: 'postcss',
                            options: {
                                sourceMap: true,
                                plugins: () => [
                                    // Note that we use significantly fewer plugins on the plain
                                    // CSS parser. If we start to parse plain CSS, we end with all
                                    // kinds of nasty problems (like stylesheets not loading).
                                    //
                                    // You might have noticed that we're also sending regular CSS
                                    // through PostCSS. This looks weird, and in fact is probably
                                    // not what you'd expect, however in order for our CSS build
                                    // to work nicely we have to do this. Because down the line
                                    // our SCSS stylesheets reference plain CSS we have to load
                                    // the plain CSS through PostCSS so it can find it safely. This
                                    // also acts like a babel-for-css by transpiling our (S)CSS
                                    // down/up to the right browser support (prefixes, etc).
                                    // Further, if we don't do this then PostCSS assumes that our
                                    // plain CSS is SCSS and it really doesn't like that, even
                                    // though plain CSS should be compatible. The chunking options
                                    // at the top of this webpack config help group the SCSS and
                                    // plain CSS together for the bundler.

                                    require("postcss-simple-vars")(),
                                    require("postcss-strip-inline-comments")(),
                                    require("postcss-hexrgba")(),

                                    // It's important that this plugin is last otherwise we end
                                    // up with broken CSS.
                                    require('postcss-preset-env')({stage: 3, browsers: 'last 2 versions'}),
                                ],
                                parser: "postcss-scss",
                                "local-plugins": true,
                            },
                        },
                    ]
                },
                {
                    test: /\.scss$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        {
                            loader: 'css-loader',
                            options: {
                                importLoaders: 1,
                                sourceMap: true,
                            }
                        },
                        {
                            loader: 'postcss-loader',
                            ident: 'postcss',
                            options: {
                                sourceMap: true,
                                plugins: () => [
                                    // Note that we use slightly different plugins for SCSS.

                                    require('postcss-import')(),
                                    require("postcss-mixins")(),
                                    require("postcss-simple-vars")(),
                                    require("postcss-extend")(),
                                    require("postcss-nested")(),
                                    require("postcss-easings")(),
                                    require("postcss-strip-inline-comments")(),
                                    require("postcss-hexrgba")(),

                                    // It's important that this plugin is last otherwise we end
                                    // up with broken CSS.
                                    require('postcss-preset-env')({stage: 3, browsers: 'last 2 versions'}),
                                ],
                                parser: "postcss-scss",
                                "local-plugins": true,
                            },
                        },
                    ]
                },
                {
                    test: /\.wasm$/,
                    loader: "file-loader",
                    type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
                    options: {
                        name: '[name].[hash:7].[ext]',
                        outputPath: '.',
                    },
                },
                {
                    // cache-bust languages.json file placed in
                    // riot-web/webapp/i18n during build by copy-res.js
                    test: /\.*languages.json$/,
                    type: "javascript/auto",
                    loader: 'file-loader',
                    options: {
                        name: 'i18n/[name].[hash:7].[ext]',
                    },
                },
                {
                    test: /\.(gif|png|svg|ttf|woff|woff2|xml|ico)$/,
                    // Use a content-based hash in the name so that we can set a long cache
                    // lifetime for assets while still delivering changes quickly.
                    oneOf: [
                        {
                            // Assets referenced in CSS files
                            issuer: /\.(scss|css)$/,
                            loader: 'file-loader',
                            options: {
                                esModule: false,
                                name: '[name].[hash:7].[ext]',
                                outputPath: getImgOutputPath,
                                publicPath: function(url, resourcePath) {
                                    // CSS image usages end up in the `bundles/[hash]` output
                                    // directory, so we adjust the final path to navigate up
                                    // twice.
                                    const outputPath = getImgOutputPath(url, resourcePath);
                                    return toPublicPath(path.join("../..", outputPath));
                                },
                            },
                        },
                        {
                            // Assets referenced in HTML and JS files
                            loader: 'file-loader',
                            options: {
                                esModule: false,
                                name: '[name].[hash:7].[ext]',
                                outputPath: getImgOutputPath,
                                publicPath: function(url, resourcePath) {
                                    const outputPath = getImgOutputPath(url, resourcePath);
                                    return toPublicPath(outputPath);
                                },
                            },
                        },
                    ],
                },
            ]
        },

        plugins: [
            new webpack.DefinePlugin({
                'process.env': {
                    NODE_ENV: JSON.stringify(process.env.NODE_ENV),
                },
            }),

            // This exports our CSS using the splitChunks and loaders above.
            new MiniCssExtractPlugin({
                filename: 'bundles/[hash]/[name].css',
                ignoreOrder: false, // Enable to remove warnings about conflicting order
            }),

            // This is the app's main entry point.
            new HtmlWebpackPlugin({
                template: './src/vector/index.html',

                // we inject the links ourselves via the template, because
                // HtmlWebpackPlugin will screw up our formatting like the names
                // of the themes and which chunks we actually care about.
                inject: false,
                excludeChunks: ['mobileguide', 'usercontent', 'jitsi'],
                minify: argv.mode === 'production',
                vars: {
                    og_image_url: og_image_url,
                },
            }),

            // This is the jitsi widget wrapper (embedded, so isolated stack)
            new HtmlWebpackPlugin({
                template: './src/vector/jitsi/index.html',
                filename: 'jitsi.html',
                minify: argv.mode === 'production',
                chunks: ['jitsi'],
            }),

            // This is the mobile guide's entry point (separate for faster mobile loading)
            new HtmlWebpackPlugin({
                template: './src/vector/mobile_guide/index.html',
                filename: 'mobile_guide/index.html',
                minify: argv.mode === 'production',
                chunks: ['mobileguide'],
            }),

            // These are the static error pages for when the javascript env is *really unsupported*
            new HtmlWebpackPlugin({
                template: './src/vector/static/unable-to-load.html',
                filename: 'static/unable-to-load.html',
                minify: argv.mode === 'production',
                chunks: [],
            }),
            new HtmlWebpackPlugin({
                template: './src/vector/static/incompatible-browser.html',
                filename: 'static/incompatible-browser.html',
                minify: argv.mode === 'production',
                chunks: [],
            }),

            // This is the usercontent sandbox's entry point (separate for iframing)
            new HtmlWebpackPlugin({
                template: './node_modules/matrix-react-sdk/src/usercontent/index.html',
                filename: 'usercontent/index.html',
                minify: argv.mode === 'production',
                chunks: ['usercontent'],
            }),
        ],

        output: {
            path: path.join(__dirname, "webapp"),

            // The generated JS (and CSS, from the extraction plugin) are put in a
            // unique subdirectory for the build. There will only be one such
            // 'bundle' directory in the generated tarball; however, hosting
            // servers can collect 'bundles' from multiple versions into one
            // directory and symlink it into place - this allows users who loaded
            // an older version of the application to continue to access webpack
            // chunks even after the app is redeployed.
            filename: "bundles/[hash]/[name].js",
            chunkFilename: "bundles/[hash]/[name].js",
        },

        // configuration for the webpack-dev-server
        devServer: {
            // serve unwebpacked assets from webapp.
            contentBase: './webapp',

            // Only output errors, warnings, or new compilations.
            // This hides the massive list of modules.
            stats: 'minimal',

            // hot module replacement doesn't work (I think we'd need react-hot-reload?)
            // so webpack-dev-server reloads the page on every update which is quite
            // tedious in Riot since that can take a while.
            hot: false,
            inline: false,
        },
    };
};

/**
 * Merge assets found via CSS and imports into a single tree, while also preserving
 * directories under `res`.
 *
 * @param {string} url The adjusted name of the file, such as `warning.1234567.svg`.
 * @param {string} resourcePath The absolute path to the source file with unmodified name.
 * @return {string} The returned paths will look like `img/warning.1234567.svg`.
 */
function getImgOutputPath(url, resourcePath) {
    const prefix = /^.*[/\\]res[/\\]/;
    const outputDir = path.dirname(resourcePath).replace(prefix, "");
    return path.join(outputDir, path.basename(url));
}

/**
 * Convert path to public path format, which always uses forward slashes, since it will
 * be placed directly into things like CSS files.
 *
 * @param {string} path Some path to a file.
 */
function toPublicPath(path) {
    return path.replace(/\\/g, '/');
}
<|endoftext|>


<commit_before>var jsxLoaders = ['babel-loader?stage=1'];

module.exports = {
  cache: true,
  entry: './app',
  output: {
    filename: 'dist/bundle.min.js',
    filename: 'bundle.min.js'
  },
  module: {
    loaders: [
      { test: /\.jsx$/, exclude: /amaphiko-web\/node_modules/, loaders: jsxLoaders },
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx', '.json']
  }
};
<commit_msg>Remove bundle from dist since it gets copied in npm task<commit_after>var jsxLoaders = ['babel-loader?stage=1'];

module.exports = {
  cache: true,
  entry: './app',
  output: {
    filename: 'bundle.min.js'
  },
  module: {
    loaders: [
      { test: /\.jsx$/, exclude: /amaphiko-web\/node_modules/, loaders: jsxLoaders },
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx', '.json']
  }
};
<|endoftext|>


<commit_before>module.exports = {
    entry: './app/main.js',
    output: {
        path: __dirname + '/public/js/',
        filename: 'bundle.js'
    },
    module: {
        loaders: [{
            test: /\.css$/,
            loader: "style!css"
        }, {
            test: /\.js$/,
            loader: "babel-loader"
        }]
    },
    resolveLoader: {
        root: './node_modules'
    }
};<commit_msg>updated root back<commit_after>module.exports = {
    entry: './app/main.js',
    output: {
        path: __dirname + '/public/js/',
        filename: 'bundle.js'
    },
    module: {
        loaders: [{
            test: /\.css$/,
            loader: "style!css"
        }, {
            test: /\.js$/,
            loader: "babel-loader"
        }]
    },
    resolveLoader: {
        root: __dirname + '/node_modules'
    }
};<|endoftext|>


<commit_before>const {resolve}         = require('path');
const webpack           = require('webpack');
const HTMLPlugin        = require('html-webpack-plugin');
const CopyPlugin        = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyCSSPlugin   = require('purifycss-webpack-plugin');

const removeEmpty = array => array.filter(i => !!i);

module.exports = env => {

  const isTest = process.env.NODE_ENV === 'test';
  const isProd = env.prod ? true : false;

  return {

    entry  : {
      app   : resolve(__dirname, 'front', 'app', 'index.js'),
      vendor: ['react', 'react-dom', 'react-router-dom', 'ramda', 'gsap']
    },
    output : {
      path      : resolve(__dirname, 'front', 'www'),
      filename  : '[name].[hash].js',
      publicPath: isProd ? '' : '/'
    },
    devtool: isProd ? 'source-map' : 'eval', //cheap-module-
    module : {
      rules: [
        {
          test  : /\.(s?)(a|c)ss$/,
          loader: ExtractTextPlugin.extract({
            use     : ['css-loader', 'postcss-loader', 'sass-loader'],
            fallback: 'style-loader'
          })
        },
        {
          test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
          use : 'file-loader?name=[name].[ext]'
        },
        {
          test   : /\.(jpe?g|png|gif|svg)$/i,
          loaders: ['file-loader?hash=sha512&digest=hex&name=[hash].[ext]', {
            loader: 'image-webpack-loader',
            query : {
              mozjpeg : { progressive: true },
              gifsicle: { interlaced: false },
              optipng : { optimizationLevel: 7 },
              pngquant: { quality: '75-90', speed: 3 },
            },
          }]
        },
        {
          enforce: 'pre',
          test   : /\.js$/,
          exclude: ['/node_modules/', '/app/vendor/'],
          loader : 'eslint-loader',
          options: { configFile: resolve(__dirname, '.eslintrc') }
        },
        {
          test   : /\.js$/,
          loader : 'babel-loader',
          exclude: resolve(__dirname, 'node_modules/'),
          options  : {
            plugins: [
              "transform-class-properties",
              "transform-object-rest-spread",
              "transform-es2015-destructuring",
              "emotion"
            ],
            presets: removeEmpty(['es2015', 'react', isProd ? undefined : 'react-hmre']),
            compact: false,
            comments: false
          }
        }
      ]
    },
    plugins: removeEmpty([
      new HTMLPlugin({
        title   : 'Application',
        template: 'front/app/index.html'
      }),
      new CopyPlugin([
        {from: resolve(__dirname, 'front', 'app', 'config.json')},
        {from: resolve(__dirname, 'front', 'app', 'favicon.ico')}
      ]),
      new ExtractTextPlugin({
        filename : 'style.css',
        allChunks: true,
        disable  : false
      }),
      //Disable for tests
      isTest ? null : new webpack.optimize.CommonsChunkPlugin({
        name     : 'vendor',
        minChunks: Infinity,
        filename : '[name].[hash].js',
      }),
      !isProd ? null : new webpack.DefinePlugin({
        'process.env': {NODE_ENV: '"production"'}
      }),
      !isProd ? null : new webpack.optimize.UglifyJsPlugin({
        mangle: false
      }),
      !isProd ? null : new PurifyCSSPlugin({
        basePath     : __dirname,
        purifyOptions: {
          info  : true,
          minify: true
        }
      }),
      !isProd ? null : new webpack.optimize.OccurrenceOrderPlugin()
    ])
  };
};
<commit_msg>Change prod source map<commit_after>const {resolve}         = require('path');
const webpack           = require('webpack');
const HTMLPlugin        = require('html-webpack-plugin');
const CopyPlugin        = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyCSSPlugin   = require('purifycss-webpack-plugin');

const removeEmpty = array => array.filter(i => !!i);

module.exports = env => {

  const isTest = process.env.NODE_ENV === 'test';
  const isProd = env.prod ? true : false;

  return {

    entry  : {
      app   : resolve(__dirname, 'front', 'app', 'index.js'),
      vendor: ['react', 'react-dom', 'react-router-dom', 'ramda', 'gsap']
    },
    output : {
      path      : resolve(__dirname, 'front', 'www'),
      filename  : '[name].[hash].js',
      publicPath: isProd ? '' : '/'
    },
    devtool: isProd ? 'cheap-module-source-map' : 'eval',
    module : {
      rules: [
        {
          test  : /\.(s?)(a|c)ss$/,
          loader: ExtractTextPlugin.extract({
            use     : ['css-loader', 'postcss-loader', 'sass-loader'],
            fallback: 'style-loader'
          })
        },
        {
          test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
          use : 'file-loader?name=[name].[ext]'
        },
        {
          test   : /\.(jpe?g|png|gif|svg)$/i,
          loaders: ['file-loader?hash=sha512&digest=hex&name=[hash].[ext]', {
            loader: 'image-webpack-loader',
            query : {
              mozjpeg : { progressive: true },
              gifsicle: { interlaced: false },
              optipng : { optimizationLevel: 7 },
              pngquant: { quality: '75-90', speed: 3 },
            },
          }]
        },
        {
          enforce: 'pre',
          test   : /\.js$/,
          exclude: ['/node_modules/', '/app/vendor/'],
          loader : 'eslint-loader',
          options: { configFile: resolve(__dirname, '.eslintrc') }
        },
        {
          test   : /\.js$/,
          loader : 'babel-loader',
          exclude: resolve(__dirname, 'node_modules/'),
          options  : {
            plugins: [
              "transform-class-properties",
              "transform-object-rest-spread",
              "transform-es2015-destructuring",
              "emotion"
            ],
            presets: removeEmpty(['es2015', 'react', isProd ? undefined : 'react-hmre']),
            compact: false,
            comments: false
          }
        }
      ]
    },
    plugins: removeEmpty([
      new HTMLPlugin({
        title   : 'Application',
        template: 'front/app/index.html'
      }),
      new CopyPlugin([
        {from: resolve(__dirname, 'front', 'app', 'config.json')},
        {from: resolve(__dirname, 'front', 'app', 'favicon.ico')}
      ]),
      new ExtractTextPlugin({
        filename : 'style.css',
        allChunks: true,
        disable  : false
      }),
      //Disable for tests
      isTest ? null : new webpack.optimize.CommonsChunkPlugin({
        name     : 'vendor',
        minChunks: Infinity,
        filename : '[name].[hash].js',
      }),
      !isProd ? null : new webpack.DefinePlugin({
        'process.env': {NODE_ENV: '"production"'}
      }),
      !isProd ? null : new webpack.optimize.UglifyJsPlugin({
        mangle: false
      }),
      !isProd ? null : new PurifyCSSPlugin({
        basePath     : __dirname,
        purifyOptions: {
          info  : true,
          minify: true
        }
      }),
      !isProd ? null : new webpack.optimize.OccurrenceOrderPlugin()
    ])
  };
};
<|endoftext|>


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

var webpackConfig = {
	entry: "./client/app.js",
	output: {
		path: "build",
		filename: "bundle.js"
	},
	module: {
		loaders: [
			{
				loader: "babel-loader",
				test: /\.js$/,
				exclude: /node_modules/,
		        query: {
		        	presets: ['es2015', 'react']
		        }
			}
		]
	}
};

module.exports = webpackConfig;<commit_msg>Adding assets loaders to webpack config<commit_after>var webpack = require('webpack');

var webpackConfig = {
	entry: "./client/app.js",
	output: {
		path: "build",
		filename: "bundle.js"
	},
	module: {
		loaders: [
			{
				loader: "babel-loader",
				test: /\.js$/,
				exclude: /node_modules/,
		        query: {
		        	presets: ['es2015', 'react']
		        }
			},
		    {
		        test: /\.css$/,
		        loader: "style-loader!css-loader"
		    },
			{
				test: /\.png$/,
				loader: "url-loader?limit=100000"
			},
			{
				test: /\.jpg$/,
				loader: "file-loader"
			},
			{
				test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
				loader: 'url?limit=10000&mimetype=application/font-woff'
			},
			{
				test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
				loader: 'url?limit=10000&mimetype=application/octet-stream'
			},
			{
				test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
				loader: 'file'
			},
			{
				test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
				loader: 'url?limit=10000&mimetype=image/svg+xml'
			}
		]
	}
};

module.exports = webpackConfig;<|endoftext|>


<commit_before>var _ = require('lodash'),
    path = require('path'),
    webpack = require('webpack'),
    ExtractTextPlugin = require('extract-text-webpack-plugin'),
    project = require('./package.json'),

    rootPath = path.resolve(__dirname),
    sourcePath = path.join(rootPath, 'src/'),
    buildPath = path.join(rootPath, 'build/'),
    nodePath = path.join(rootPath, 'node_modules'),

    isDevelopment = process.env.NODE_ENV !== 'production',
    banner = _.template(
        '<%= name %> v<%= version %>\n' +
        '<%= description %>\n' +
        '@author <%= author %>'
    )(project);

// @todo: dev-configuration for proxy server
// @todo: sourcemap only for chunk with real sources
// @todo: debug-mode
// @todo: stage=0 and static properties for default props and prop types

var entryApp = [path.join(sourcePath, 'app.js')],
    plugins = [
        new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.bundle.js'),
        new webpack.ProvidePlugin({
            React: 'react',
            ReactDOM: 'react-dom',
            block: 'bem-cn'
        })
    ],
    stylusLoader = 'style-loader!css-loader!stylus-loader';

/*
 * Development build:
 * — react-hot-loader
 */
if (isDevelopment) {
    entryApp = [
        'webpack-hot-middleware/client'
    ].concat(entryApp);

    plugins = plugins.concat([
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin()
    ]);

/*
 * Production build:
 * — minification
 * — sepatate bundle for css
 * — banner for minified files
 * — optimizied production build for React (thru NODE_ENV variable)
 */
} else {
    plugins = plugins.concat([
        new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.bundle.js'),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('production')
            }
        }),
        new ExtractTextPlugin('[name].css', {
            allChunks: true
        }),
        new webpack.BannerPlugin(banner)
    ]);

    stylusLoader = ExtractTextPlugin.extract('style-loader', 'css-loader!stylus-loader');
}

module.exports = {
    entry: {
        app: entryApp,
        vendors: [
            'react',
            'react-dom',
            'react-router'
        ]
    },
    resolve: {
        root: [sourcePath]
    },
    resolveLoader: {
        root: [nodePath]
    },
    output: {
        path: buildPath,
        publicPath: '/build/',
        filename: 'app.bundle.js'
    },
    module: {
        preLoaders: [
            {
                test: /\.(js|jsx)$/,
                loader: 'eslint-loader'
            }
        ],
        loaders: [
            {
                test: /\.(js|jsx)$/,
                exclude: nodePath,
                loaders: ['babel']
            },
            {
                test: /\.styl$/,
                loader: stylusLoader
            },
            {
                test: /\.css$/,
                loaders: ['style', 'css']
            },
            {
                test: /\.png$/,
                loader: 'file-loader'
            }
        ]
    },
    plugins: plugins
};
<commit_msg>More complete vendor bundle<commit_after>var _ = require('lodash'),
    path = require('path'),
    webpack = require('webpack'),
    ExtractTextPlugin = require('extract-text-webpack-plugin'),
    project = require('./package.json'),

    rootPath = path.resolve(__dirname),
    sourcePath = path.join(rootPath, 'src/'),
    buildPath = path.join(rootPath, 'build/'),
    nodePath = path.join(rootPath, 'node_modules'),

    isDevelopment = process.env.NODE_ENV !== 'production',
    banner = _.template(
        '<%= name %> v<%= version %>\n' +
        '<%= description %>\n' +
        '@author <%= author %>'
    )(project);

// @todo: dev-configuration for proxy server
// @todo: sourcemap only for chunk with real sources
// @todo: debug-mode
// @todo: stage=0 and static properties for default props and prop types

var entryApp = [path.join(sourcePath, 'app.js')],
    plugins = [
        new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.bundle.js'),
        new webpack.ProvidePlugin({
            React: 'react',
            ReactDOM: 'react-dom',
            block: 'bem-cn'
        })
    ],
    stylusLoader = 'style-loader!css-loader!stylus-loader';

/*
 * Development build:
 * — react-hot-loader
 */
if (isDevelopment) {
    entryApp = [
        'webpack-hot-middleware/client'
    ].concat(entryApp);

    plugins = plugins.concat([
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin()
    ]);

/*
 * Production build:
 * — minification
 * — sepatate bundle for css
 * — banner for minified files
 * — optimizied production build for React (thru NODE_ENV variable)
 */
} else {
    plugins = plugins.concat([
        new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.bundle.js'),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('production')
            }
        }),
        new ExtractTextPlugin('[name].css', {
            allChunks: true
        }),
        new webpack.BannerPlugin(banner)
    ]);

    stylusLoader = ExtractTextPlugin.extract('style-loader', 'css-loader!stylus-loader');
}

module.exports = {
    entry: {
        app: entryApp,
        vendors: [
            'react',
            'react-dom',
            'react-router',
            'history',
            'bem-cn'
        ]
    },
    resolve: {
        root: [sourcePath]
    },
    resolveLoader: {
        root: [nodePath]
    },
    output: {
        path: buildPath,
        publicPath: '/build/',
        filename: 'app.bundle.js'
    },
    module: {
        preLoaders: [
            {
                test: /\.(js|jsx)$/,
                loader: 'eslint-loader'
            }
        ],
        loaders: [
            {
                test: /\.(js|jsx)$/,
                exclude: nodePath,
                loaders: ['babel']
            },
            {
                test: /\.styl$/,
                loader: stylusLoader
            },
            {
                test: /\.css$/,
                loaders: ['style', 'css']
            },
            {
                test: /\.png$/,
                loader: 'file-loader'
            }
        ]
    },
    plugins: plugins
};
<|endoftext|>


<commit_before>var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin')

const DEBUG = !(process.env.NODE_ENV === 'production')
const VERBOSE = process.argv.includes('--verbose')
const HOT_DEPLOY = !!process.env.HOT_DEPLOY
let CONTEXT_PATH = `${(process.env.CONTEXT_PATH || '')}`

module.exports = {
  context: __dirname + '/src/main/client',
  entry: {
    'js/bundle': [...(HOT_DEPLOY ? ['webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'] : []), './index.js']
  },
  output: {
    path: __dirname + '/src/main/resources/static',
    filename: 'assets/[name].js',
    publicPath: `${CONTEXT_PATH}/`
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devtool: DEBUG ? 'cheap-source-map' : false,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.CONTEXT_PATH': `"${CONTEXT_PATH}"`,
      'process.env.NODE_ENV': `"${process.env.NODE_ENV || (DEBUG ? 'development' : 'production')}"`
    }),
    ...(HOT_DEPLOY ? [new webpack.HotModuleReplacementPlugin()] : []),
    ...(DEBUG ? [] : [new webpack.optimize.AggressiveMergingPlugin(),
      new webpack.optimize.UglifyJsPlugin({ compress: { screw_ie8: true, warnings: VERBOSE } })
    ]),
    new HtmlWebpackPlugin({
      title: 'himawari',
      template: 'index.ejs'
    }),
    new CopyWebpackPlugin([
      { from: 'assets'}
    ])
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.ejs$/,
        loader: 'ejs-loader'
      }
    ]
  }
}
<commit_msg>source mapの種類調整<commit_after>var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin')

const DEBUG = !(process.env.NODE_ENV === 'production')
const VERBOSE = process.argv.includes('--verbose')
const HOT_DEPLOY = !!process.env.HOT_DEPLOY
let CONTEXT_PATH = `${(process.env.CONTEXT_PATH || '')}`

module.exports = {
  context: __dirname + '/src/main/client',
  entry: {
    'js/bundle': [...(HOT_DEPLOY ? ['webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'] : []), './index.js']
  },
  output: {
    path: __dirname + '/src/main/resources/static',
    filename: 'assets/[name].js',
    publicPath: `${CONTEXT_PATH}/`
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devtool: DEBUG ? 'cheap-module-eval-source-map' : false,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.CONTEXT_PATH': `"${CONTEXT_PATH}"`,
      'process.env.NODE_ENV': `"${process.env.NODE_ENV || (DEBUG ? 'development' : 'production')}"`
    }),
    ...(HOT_DEPLOY ? [new webpack.HotModuleReplacementPlugin()] : []),
    ...(DEBUG ? [] : [new webpack.optimize.AggressiveMergingPlugin(),
      new webpack.optimize.UglifyJsPlugin({ compress: { screw_ie8: true, warnings: VERBOSE } })
    ]),
    new HtmlWebpackPlugin({
      title: 'himawari',
      template: 'index.ejs'
    }),
    new CopyWebpackPlugin([
      { from: 'assets'}
    ])
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.ejs$/,
        loader: 'ejs-loader'
      }
    ]
  }
}
<|endoftext|>


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

module.exports = {
  entry: [
    path.join(__dirname, 'app/Main.js')
  ],
  output: {
    path: path.join(__dirname, 'public/js'),
    filename: 'bundle.js'
    // publicPath: 'http://www.daviepoplarcapital.com/'
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/i,
        exclude: /node_modules/,
        loader: 'babel'
      }, {
        test: /\.scss$/i,
        loaders: [
          'style',
          'css',
          'autoprefixer?browsers=last 3 versions',
          'sass?outputStyle=expanded'
        ]
      }, {
        test: /\.json$/i,
        loader: 'json'
      }, {
        test: /\.(jpe?g|png|gif|svg)$/i,
        loader: 'file-loader?name=/images/[name].[ext]'
      }
    ]
  },
  watch: true,
  devtool: 'cheap-eval-source-map',
  devServer: {
    // contentBase: './public',
    inline: true,
    port: 8100
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin(),
    new webpack.optimize.AggressiveMergingPlugin()
  ],
  stats: {
    colors: true,
    modules: true,
    reasons: true,
    errorDetails: true
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  }
};

/*
module.exports = {
  devtool: 'cheap-eval-source-map',
  entry: [
    path.join(__dirname, './app/app.js')
    // path.join(__dirname, './app/app.js')
  ],
  output: {
    path: path.join(__dirname, 'public'),
    filename: './js/bundle.js',
    publicPath: 'http://www.daviepoplarcapital.com/'
    // sourceMapFilename: "public/js/bundle.map"
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/i,
        exclude: /node_modules/,
        loaders: ['babel']
      }
      // , {
      //   test: /\.(jpe?g|png|gif|svg)$/i,
      //   loader: 'file-loader?name=/images/[name].[ext]'
      // }, {
      //   test: /\.pdf/i,
      //   loader: 'file-loader?name=/docs/[name].[ext]'
      // }
    ]
  },
  devServer: {
    colors: true,
    contentBase: __dirname,
    noInfo: false,
    hot: true,
    inline: true,
    port: 3000,
    host: 'localhost'
  },
  plugins: []
};
*/
<commit_msg>config: Include test for use of file-loader package<commit_after>const webpack = require('webpack');
const path = require('path');

module.exports = {
  entry: [
    path.join(__dirname, 'app/Main.js')
  ],
  output: {
    path: path.join(__dirname, 'public/js'),
    filename: 'bundle.js'
    // publicPath: 'http://www.daviepoplarcapital.com/'
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/i,
        exclude: /node_modules/,
        loader: 'babel'
      }, {
        test: /\.scss$/i,
        loaders: [
          'style',
          'css',
          'autoprefixer?browsers=last 3 versions',
          'sass?outputStyle=expanded'
        ]
      }, {
        test: /\.json$/i,
        loader: 'json'
      }, {
        test: /\.(pdf|vcf|docx?)$/i,
        loader: 'file-loader?name=/resources/[name].[ext]'
      }, {
        test: /\.(jpe?g|png|gif|svg)$/i,
        loader: 'file-loader?name=/images/[name].[ext]'
      }
    ]
  },
  watch: true,
  devtool: 'cheap-eval-source-map',
  devServer: {
    // contentBase: './public',
    inline: true,
    port: 8100
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin(),
    new webpack.optimize.AggressiveMergingPlugin()
  ],
  stats: {
    colors: true,
    modules: true,
    reasons: true,
    errorDetails: true
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  }
};

/*
module.exports = {
  devtool: 'cheap-eval-source-map',
  entry: [
    path.join(__dirname, './app/app.js')
    // path.join(__dirname, './app/app.js')
  ],
  output: {
    path: path.join(__dirname, 'public'),
    filename: './js/bundle.js',
    publicPath: 'http://www.daviepoplarcapital.com/'
    // sourceMapFilename: "public/js/bundle.map"
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/i,
        exclude: /node_modules/,
        loaders: ['babel']
      }
      // , {
      //   test: /\.(jpe?g|png|gif|svg)$/i,
      //   loader: 'file-loader?name=/images/[name].[ext]'
      // }, {
      //   test: /\.pdf/i,
      //   loader: 'file-loader?name=/docs/[name].[ext]'
      // }
    ]
  },
  devServer: {
    colors: true,
    contentBase: __dirname,
    noInfo: false,
    hot: true,
    inline: true,
    port: 3000,
    host: 'localhost'
  },
  plugins: []
};
*/
<|endoftext|>


<commit_before>/* global process */
var webpack = require('webpack'),
    WebpackShellPlugin = require('webpack-shell-plugin');
var production = (process.env.NODE_ENV === 'production'),
    plugins = [];

/*
 * Configure production-only plugins
 */
if (production) {
  plugins.push(new webpack.DefinePlugin({
                  'process.env': {
                    'NODE_ENV': JSON.stringify('production')
                  }
                }));

  plugins.push(new webpack.optimize.UglifyJsPlugin({
                  compress: {
                    // ignore warnings from uglify
                    warnings: false
                  }
                }));
}

/*
 * Uglify plugin requires that bundle have .js extension for minimization to occur.
 * But the SproutCore build system fails if the bundle is in the application folder
 * and has a .js extension because the YUI compressor chokes on the minimized bundle.
 * Therefore, we build the bundle with a .js extension initially and then rename it
 * with the .js.ignore extension after all plugins have run.
 */
var bundlePath = 'apps/dg/resources/build',
    srcBundleName = 'codap-lib-bundle.js',
    dstBundleName = 'codap-lib-bundle.js.ignore',
    srcBundle = bundlePath + '/' + srcBundleName,
    dstBundle = bundlePath + '/' + dstBundleName,
    echoCmd = "echo Renaming '" + srcBundleName + "' to '" + dstBundleName + "'...\n",
    renameBundleCmd = ['mv', srcBundle, dstBundle].join(' ');
plugins.push(new WebpackShellPlugin({
                onBuildEnd: [echoCmd, renameBundleCmd]
              }));

/*
 * Configuration
 */
var config = {
  entry: './webpack-entry.js',
  output: {
    path: bundlePath,
    filename: 'codap-lib-bundle.js'
  },
  plugins: plugins,
  performance: {
    // turn off bundle size warnings
    hints: false
  }
};

module.exports = config;
<commit_msg>Use srcBundleName to eliminate redundant string constant.<commit_after>/* global process */
var webpack = require('webpack'),
    WebpackShellPlugin = require('webpack-shell-plugin');
var production = (process.env.NODE_ENV === 'production'),
    plugins = [];

/*
 * Configure production-only plugins
 */
if (production) {
  plugins.push(new webpack.DefinePlugin({
                  'process.env': {
                    'NODE_ENV': JSON.stringify('production')
                  }
                }));

  plugins.push(new webpack.optimize.UglifyJsPlugin({
                  compress: {
                    // ignore warnings from uglify
                    warnings: false
                  }
                }));
}

/*
 * Uglify plugin requires that bundle have .js extension for minimization to occur.
 * But the SproutCore build system fails if the bundle is in the application folder
 * and has a .js extension because the YUI compressor chokes on the minimized bundle.
 * Therefore, we build the bundle with a .js extension initially and then rename it
 * with the .js.ignore extension after all plugins have run.
 */
var bundlePath = 'apps/dg/resources/build',
    srcBundleName = 'codap-lib-bundle.js',
    dstBundleName = 'codap-lib-bundle.js.ignore',
    srcBundle = bundlePath + '/' + srcBundleName,
    dstBundle = bundlePath + '/' + dstBundleName,
    echoCmd = "echo Renaming '" + srcBundleName + "' to '" + dstBundleName + "'...\n",
    renameBundleCmd = ['mv', srcBundle, dstBundle].join(' ');
plugins.push(new WebpackShellPlugin({
                onBuildEnd: [echoCmd, renameBundleCmd]
              }));

/*
 * Configuration
 */
var config = {
  entry: './webpack-entry.js',
  output: {
    path: bundlePath,
    filename: srcBundleName
  },
  plugins: plugins,
  performance: {
    // turn off bundle size warnings
    hints: false
  }
};

module.exports = config;
<|endoftext|>


<commit_before>/*
 * Copyright (c) (2017) - Aikar's Minecraft Timings Parser
 *
 *  Written by Aikar <aikar@aikar.co>
 *    + Contributors (See AUTHORS)
 *
 *  http://aikar.co
 *  http://starlis.com
 *
 *  @license MIT
 *
 */
let webpack = require('webpack');
let path = require('path');
module.exports = {
	context: __dirname,
	entry: path.join(__dirname, "static/js/timings"),
	output: {
		path: path.join(__dirname, "static/dist/"),
		publicPath: "static/dist/", // relative path for github pages
		filename: "timings.js",
		//chunkFilename: "[hash]/js/[id].js",
		//hotUpdateMainFilename: "[hash]/update.json",
		//hotUpdateChunkFilename: "[hash]/js/[id].update.js"
	},
	resolve: {
		extensions: ['', '.js', '.jsx']
	},
	//recordsOutputPath: path.join(__dirname, "records.json"),
	module: {
		loaders: [
			{
				test: [/\.(js|jsx)$/],
				exclude: /node_modules/,
				loader: 'babel',

				query: {
					presets: ['react', 'es2015', 'stage-1']
				}
			},
			{ test: /\.json$/,   loader: "json" },
			{ test: /\.coffee$/, loader: "coffee" },
			{ test: /\.css$/,    loader: "style" },
			{
				test: /\.sass$/,
				loader: "style!sass!autoprefixer"
			},
			{ test: /\.png$/,    loader: "url?prefix=img/&limit=5000" },
			{ test: /\.jpg$/,    loader: "url?prefix=img/&limit=5000" },
			{ test: /\.gif$/,    loader: "url?prefix=img/&limit=5000" },
			{ test: /\.woff$/,   loader: "url?prefix=font/&limit=5000" },
			{ test: /\.eot$/,    loader: "file?prefix=font/" },
			{ test: /\.ttf$/,    loader: "file?prefix=font/" },
			{ test: /\.svg$/,    loader: "file?prefix=font/" },
		]
	},
	plugins: [
		new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }),
	],
	node: {
		fs: 'empty',
		net: 'empty',
		tls: 'empty'
	}
};
function escapeRegExpString(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }
function pathToRegExp(p) { return new RegExp("^" + escapeRegExpString(p)); }
<commit_msg>add comment<commit_after>/*
 * Copyright (c) (2017) - Aikar's Minecraft Timings Parser
 *
 *  Written by Aikar <aikar@aikar.co>
 *    + Contributors (See AUTHORS)
 *
 *  http://aikar.co
 *  http://starlis.com
 *
 *  @license MIT
 *
 */
let webpack = require('webpack');
let path = require('path');
module.exports = {
	context: __dirname,
	entry: path.join(__dirname, "static/js/timings"),
	output: {
		path: path.join(__dirname, "static/dist/"),
		publicPath: "static/dist/", // relative path for github pages
		filename: "timings.js",
		//chunkFilename: "[hash]/js/[id].js",
		//hotUpdateMainFilename: "[hash]/update.json",
		//hotUpdateChunkFilename: "[hash]/js/[id].update.js"
	},
	resolve: {
		extensions: ['', '.js', '.jsx']
	},
	//recordsOutputPath: path.join(__dirname, "records.json"),
	module: {
		loaders: [
			{
				test: [/\.(js|jsx)$/],
				exclude: /node_modules/,
				loader: 'babel',

				query: {
					presets: ['react', 'es2015', 'stage-1']
				}
			},
			{ test: /\.json$/,   loader: "json" },
			{ test: /\.coffee$/, loader: "coffee" },
			{ test: /\.css$/,    loader: "style" },
			{
				test: /\.sass$/,
				loader: "style!sass!autoprefixer"
			},
			{ test: /\.png$/,    loader: "url?prefix=img/&limit=5000" },
			{ test: /\.jpg$/,    loader: "url?prefix=img/&limit=5000" },
			{ test: /\.gif$/,    loader: "url?prefix=img/&limit=5000" },
			{ test: /\.woff$/,   loader: "url?prefix=font/&limit=5000" },
			{ test: /\.eot$/,    loader: "file?prefix=font/" },
			{ test: /\.ttf$/,    loader: "file?prefix=font/" },
			{ test: /\.svg$/,    loader: "file?prefix=font/" },
		]
	},
	plugins: [
		new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }),
	],
	// examples for chunks: https://github.com/webpack/webpack/tree/master/examples/multiple-entry-points
	node: {
		fs: 'empty',
		net: 'empty',
		tls: 'empty'
	}
};
function escapeRegExpString(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }
function pathToRegExp(p) { return new RegExp("^" + escapeRegExpString(p)); }
<|endoftext|>