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

var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');

var entries = getEntry();
var chunks = getChunkName();

var config = {
  entry: entries,
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: '[name].js',
    publicPath: '/'
  },
  resolve: {
    //配置别名，在项目中可缩减引用路径
    extensions: ['.js', '.vue'],
    alias: {
      assets: path.join(__dirname,'/app/assets'),
      components: path.join(__dirname,'/app/components'),
      root: path.join(__dirname, 'node_modules')
    }
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.css$/, loader: ExtractTextPlugin.extract({
          fallbackLoader: 'style-loader',
          loader: 'css-loader'
        })
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'file-loader'
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        query: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  plugins: [
    new CommonsChunkPlugin({
      name: 'vendors',
      filename: 'assets/js/vendors.js',
      chunks: chunks,
      minChunks: 1
    }),
    new ExtractTextPlugin({
      filename: 'assets/css/main.css',
      allChunks: true
    })
  ],
  devServer: {
    historyApiFallback: false,
    noInfo: true,
    // proxy: {
    //   '/github': {
    //     target: 'https://github.com/github',
    //     changeOrigin: true,
    //     pathRewrite: {'^/github' : ''}
    //   }
    // },
  },
  devtool: '#eval-source-map'
};

var pages = getHtmls();
pages.forEach(function (pathname) {
  // filename 用文件夹名字
  var conf = {
    filename: pathname.substring(6, pathname.length - 4) + '.html', //生成的html存放路径，相对于path
    template: 'app/' + pathname + '.html', //html模板路径
  };

  if (chunks.indexOf(pathname) > -1) {
    conf.inject = 'body';
    conf.chunks = ['vendors', pathname];
    conf.hash = true;
  }
  config.plugins.push(new HtmlWebpackPlugin(conf));
});

module.exports = config;

function getEntry() {
  var entry = {};
  glob.sync('./app/pages/**/*.js').forEach(function (name) {
    var n = name.slice(name.lastIndexOf('app/') + 10, name.length -3);
    console.log('n = ' + n + ', m = ' + name)
    entry[n] = [name];
  });
  return entry;
}
function getChunkName () {
  var entry = [];
  glob.sync('./app/pages/**/*.js').forEach(function (name) {
    var n = name.slice(name.lastIndexOf('app/') + 10, name.length - 3);
    entry.push(n);
  });
  return entry;
}
function getHtmls() {
  var entry = [];
  glob.sync('./app/pages/**/*.html').forEach(function (name) {
    var n = name.slice(name.lastIndexOf('app/') + 4, name.length - 5);
    entry.push(n);
  });
  return entry;
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map';
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ]);
}
<commit_msg>rm console<commit_after>var path = require('path');
var webpack = require('webpack');
var glob = require('glob');

var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');

var entries = getEntry();
var chunks = getChunkName();

var config = {
  entry: entries,
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: '[name].js',
    publicPath: '/'
  },
  resolve: {
    //配置别名，在项目中可缩减引用路径
    extensions: ['.js', '.vue'],
    alias: {
      assets: path.join(__dirname,'/app/assets'),
      components: path.join(__dirname,'/app/components'),
      root: path.join(__dirname, 'node_modules')
    }
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.css$/, loader: ExtractTextPlugin.extract({
          fallbackLoader: 'style-loader',
          loader: 'css-loader'
        })
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'file-loader'
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        query: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  plugins: [
    new CommonsChunkPlugin({
      name: 'vendors',
      filename: 'assets/js/vendors.js',
      chunks: chunks,
      minChunks: 1
    }),
    new ExtractTextPlugin({
      filename: 'assets/css/main.css',
      allChunks: true
    })
  ],
  devServer: {
    historyApiFallback: false,
    noInfo: true,
    // proxy: {
    //   '/github': {
    //     target: 'https://github.com/github',
    //     changeOrigin: true,
    //     pathRewrite: {'^/github' : ''}
    //   }
    // },
  },
  devtool: '#eval-source-map'
};

var pages = getHtmls();
pages.forEach(function (pathname) {
  // filename 用文件夹名字
  var conf = {
    filename: pathname.substring(6, pathname.length - 4) + '.html', //生成的html存放路径，相对于path
    template: 'app/' + pathname + '.html', //html模板路径
  };

  if (chunks.indexOf(pathname) > -1) {
    conf.inject = 'body';
    conf.chunks = ['vendors', pathname];
    conf.hash = true;
  }
  config.plugins.push(new HtmlWebpackPlugin(conf));
});

module.exports = config;

function getEntry() {
  var entry = {};
  glob.sync('./app/pages/**/*.js').forEach(function (name) {
    var n = name.slice(name.lastIndexOf('app/') + 10, name.length -3);
    entry[n] = [name];
  });
  return entry;
}
function getChunkName () {
  var entry = [];
  glob.sync('./app/pages/**/*.js').forEach(function (name) {
    var n = name.slice(name.lastIndexOf('app/') + 10, name.length - 3);
    entry.push(n);
  });
  return entry;
}
function getHtmls() {
  var entry = [];
  glob.sync('./app/pages/**/*.html').forEach(function (name) {
    var n = name.slice(name.lastIndexOf('app/') + 4, name.length - 5);
    entry.push(n);
  });
  return entry;
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map';
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    })
  ]);
}
<|endoftext|>


<commit_before>const isProd = process.argv.indexOf("-p") !== -1;
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
  mode: isProd ? "production" : "development",
  resolve: {
    extensions: [".ts", ".tsx", ".js", ".jsx"],
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: [
          "babel-loader",
        ],
      },
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: [
          "babel-loader",
          "awesome-typescript-loader",
        ],
      },
      {
        test: /\.css$/,
        use: [
          isProd ? MiniCssExtractPlugin.loader : "style-loader",
          { loader: "css-loader", options: { importLoaders: 1 } },
          "postcss-loader",
        ],
      },
    ],
  },
  output: {
    filename: "./dist/bundle.js",
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "./dist/style.css",
    }),
  ],
};
<commit_msg>Output build artifacts to root of dist directory<commit_after>const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const isProd = process.argv.indexOf("-p") !== -1;

module.exports = {
  mode: isProd ? "production" : "development",
  resolve: {
    extensions: [".ts", ".tsx", ".js", ".jsx"],
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: [
          "babel-loader",
        ],
      },
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: [
          "babel-loader",
          "awesome-typescript-loader",
        ],
      },
      {
        test: /\.css$/,
        use: [
          isProd ? MiniCssExtractPlugin.loader : "style-loader",
          { loader: "css-loader", options: { importLoaders: 1 } },
          "postcss-loader",
        ],
      },
    ],
  },
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "style.css",
    }),
  ],
};
<|endoftext|>


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

const JS_RE = /\.js$/;
const HTML_RE = /\.html$/;
const LESS_RE = /\.less$/;
const IMG_FONTS_RE = /\.(png|woff|woff2|eot|ttf|svg)$/;
const CLIENT_PATH = [path.resolve(__dirname, 'src/client')];

const entry = [
	'babel-polyfill',
	'./src/client/app/index'
];
const preLoaders = [];
const plugins = [
	new webpack.optimize.DedupePlugin(),
	new webpack.optimize.OccurenceOrderPlugin(),
	new HtmlWebpackPlugin({ template: 'src/client/app/index.html', inject: false })
];

switch (process.env.NODE_ENV) {
	case 'dev':
		entry.unshift('webpack-hot-middleware/client');
		preLoaders.push({
			test: JS_RE,
			loader: 'eslint',
			include: CLIENT_PATH
		});
		plugins.push(new webpack.HotModuleReplacementPlugin());
		break;
	case 'prod':
		plugins.push(new webpack.optimize.UglifyJsPlugin());
		break;
}

module.exports = {
	devtool: 'cheap-module-eval-source-map',

	resolve: {
		root: CLIENT_PATH,
		extension: ['', '.js'],
		modulesDirectories: ['node_modules']
	},

	entry,

	output: {
		path: path.join(__dirname, 'dst'),
		filename: 'index.js',
		publicPath: '/'
	},

	module: {
		preLoaders,

		loaders: [{
			test: JS_RE,
			loaders: ['react-hot', 'babel-loader'],
			include: CLIENT_PATH,
			plugins: ['transform-runtime']
		}, {
			test: HTML_RE,
			loader: 'html'
		}, {
			test: LESS_RE,
			loader: 'style!css!less!postcss',
			include: CLIENT_PATH
		}, {
			test: /\.css$/,
			loader: 'style!css!postcss',
			include: CLIENT_PATH
		}, {
			test: IMG_FONTS_RE,
			loader: 'url-loader?limit=100000',
			include: CLIENT_PATH
		}]
	},

	postcss: () => [autoprefixer],

	plugins,

	serverHost: 'localhost',
	serverPort: 9000,
	indexHtmlPath: 'index.html'
};<commit_msg>[Webpack]: switched devtool regarding to env.<commit_after>const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const JS_RE = /\.js$/;
const CSS_RE = /\.css$/;
const HTML_RE = /\.html$/;
const LESS_RE = /\.less$/;
const IMG_FONTS_RE = /\.(png|woff|woff2|eot|ttf|svg)$/;
const CLIENT_PATH = [path.resolve(__dirname, 'src/client')];

const entry = [
	'babel-polyfill',
	'./src/client/app/index'
];
const preLoaders = [];
const plugins = [
	new webpack.optimize.DedupePlugin(),
	new webpack.optimize.OccurenceOrderPlugin(),
	new HtmlWebpackPlugin({ template: 'src/client/app/index.html', inject: false })
];
let devtool;

switch (process.env.NODE_ENV) {
	case 'dev':
		devtool = 'cheap-module-eval-source-map';
		entry.unshift('webpack-hot-middleware/client');
		preLoaders.push({
			test: JS_RE,
			loader: 'eslint',
			include: CLIENT_PATH
		});
		plugins.push(new webpack.HotModuleReplacementPlugin());
		break;
	case 'prod':
		devtool = 'cheap-source-map';
		plugins.push(new webpack.optimize.UglifyJsPlugin());
		break;
}

module.exports = {
	devtool,

	resolve: {
		root: CLIENT_PATH,
		extension: ['', '.js'],
		modulesDirectories: ['node_modules']
	},

	entry,

	output: {
		path: path.join(__dirname, 'dst'),
		filename: 'index.js',
		publicPath: '/'
	},

	module: {
		preLoaders,

		loaders: [{
			test: JS_RE,
			loaders: ['react-hot', 'babel-loader'],
			include: CLIENT_PATH,
			plugins: ['transform-runtime']
		}, {
			test: HTML_RE,
			loader: 'html'
		}, {
			test: LESS_RE,
			loader: 'style!css!less!postcss',
			include: CLIENT_PATH
		}, {
			test: CSS_RE,
			loader: 'style!css!postcss',
			include: CLIENT_PATH
		}, {
			test: IMG_FONTS_RE,
			loader: 'url-loader?limit=100000',
			include: CLIENT_PATH
		}]
	},

	postcss: () => [autoprefixer],

	plugins,

	serverHost: 'localhost',
	serverPort: 9000,
	indexHtmlPath: 'index.html'
};<|endoftext|>


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

module.exports = {
    entry: {
        "bundle": "./src/vector/index.js",
        "indexeddb-worker": "./src/vector/indexedbd-worker.js",

        // We ship olm.js as a separate lump of javascript. This makes it get
        // loaded via a separate <script/> tag in index.html (which loads it
        // into the browser global `Olm`), and define it as an external below.
        //
        // (we should probably make js-sdk load it asynchronously at some
        // point, so that it doesn't block the pageload, but that is a separate
        // problem)
        "olm": "./src/vector/olm-loader.js",

        // CSS themes
        "theme-light": "./src/skins/vector/css/themes/light.scss",
        "theme-dark": "./src/skins/vector/css/themes/dark.scss",
    },
    module: {
        preLoaders: [
            { test: /\.js$/, loader: "source-map-loader" },
        ],
        loaders: [
            { test: /\.json$/, loader: "json" },
            { test: /\.js$/, loader: "babel", include: path.resolve('./src') },
            {
                test: /\.scss$/,

                // 1. postcss-loader turns the SCSS into normal CSS.
                // 2. css-raw-loader turns the CSS into a javascript module
                //    whose default export is a string containing the CSS.
                //    (css-raw-loader is similar to css-loader, but the latter
                //    would also drag in the imgs and fonts that our CSS refers to
                //    as webpack inputs.)
                // 3. ExtractTextPlugin turns that string into a separate asset.
                loader: ExtractTextPlugin.extract("css-raw-loader!postcss-loader?config=postcss.config.js"),
            },
            {
                // this works similarly to the scss case, without postcss.
                test: /\.css$/,
                loader: ExtractTextPlugin.extract("css-raw-loader"),
            },
        ],
        noParse: [
            // 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/,
            /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$/,
            /olm\\(javascript\\)?olm\.js$/,
        ],
    },
    output: {
        path: path.join(__dirname, "webapp"),

        // the generated js (and CSS, from the ExtractTextPlugin) 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",
        devtoolModuleFilenameTemplate: function(info) {
            // Reading input source maps gives only relative paths here for
            // everything. Until I figure out how to fix this, this is a
            // workaround.
            // We use the relative resource path with any '../'s on the front
            // removed which gives a tree with matrix-react-sdk and vector
            // trees smashed together, but this fixes everything being under
            // various levels of '.' and '..'
            // Also, sometimes the resource path is absolute.
            return path.relative(process.cwd(), info.resourcePath).replace(/^[\/\.]*/, '');
        },
    },
    resolve: {
        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.
            "react": path.resolve('./node_modules/react'),
            "react-dom": path.resolve('./node_modules/react-dom'),
            "react-addons-perf": path.resolve('./node_modules/react-addons-perf'),

            // same goes for js-sdk
            "matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),
        },
    },
    externals: {
        "olm": "Olm",
        // Don't try to bundle electron: leave it as a commonjs dependency
        // (the 'commonjs' here means it will output a 'require')
        "electron": "commonjs electron",
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify(process.env.NODE_ENV),
            },
        }),

        new ExtractTextPlugin("bundles/[hash]/[name].css", {
            allChunks: true,
        }),

        new HtmlWebpackPlugin({
            template: './src/vector/index.html',

            // we inject the links ourselves via the template, because
            // HtmlWebpackPlugin wants to put the script tags either at the
            // bottom of <head> or the bottom of <body>, and I'm a bit scared
            // about moving them.
            inject: false,
        }),
    ],
    devtool: 'source-map',

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

        stats: {
            // don't fill the console up with a mahoosive list of modules
            chunks: false,
        },
    },
};

// olm is an optional dependency. Ignore it if it's not installed, to avoid a
// scary-looking error.
try {
    require('olm');
} catch (e) {
    console.log("Olm is not installed; not shipping it");
    delete(module.exports.entry["olm"]);
}
<commit_msg>use a character class for brevity add a comment so this madness has meaning<commit_after>const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        "bundle": "./src/vector/index.js",
        "indexeddb-worker": "./src/vector/indexedbd-worker.js",

        // We ship olm.js as a separate lump of javascript. This makes it get
        // loaded via a separate <script/> tag in index.html (which loads it
        // into the browser global `Olm`), and define it as an external below.
        //
        // (we should probably make js-sdk load it asynchronously at some
        // point, so that it doesn't block the pageload, but that is a separate
        // problem)
        "olm": "./src/vector/olm-loader.js",

        // CSS themes
        "theme-light": "./src/skins/vector/css/themes/light.scss",
        "theme-dark": "./src/skins/vector/css/themes/dark.scss",
    },
    module: {
        preLoaders: [
            { test: /\.js$/, loader: "source-map-loader" },
        ],
        loaders: [
            { test: /\.json$/, loader: "json" },
            { test: /\.js$/, loader: "babel", include: path.resolve('./src') },
            {
                test: /\.scss$/,

                // 1. postcss-loader turns the SCSS into normal CSS.
                // 2. css-raw-loader turns the CSS into a javascript module
                //    whose default export is a string containing the CSS.
                //    (css-raw-loader is similar to css-loader, but the latter
                //    would also drag in the imgs and fonts that our CSS refers to
                //    as webpack inputs.)
                // 3. ExtractTextPlugin turns that string into a separate asset.
                loader: ExtractTextPlugin.extract("css-raw-loader!postcss-loader?config=postcss.config.js"),
            },
            {
                // this works similarly to the scss case, without postcss.
                test: /\.css$/,
                loader: ExtractTextPlugin.extract("css-raw-loader"),
            },
        ],
        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$/,
        ],
    },
    output: {
        path: path.join(__dirname, "webapp"),

        // the generated js (and CSS, from the ExtractTextPlugin) 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",
        devtoolModuleFilenameTemplate: function(info) {
            // Reading input source maps gives only relative paths here for
            // everything. Until I figure out how to fix this, this is a
            // workaround.
            // We use the relative resource path with any '../'s on the front
            // removed which gives a tree with matrix-react-sdk and vector
            // trees smashed together, but this fixes everything being under
            // various levels of '.' and '..'
            // Also, sometimes the resource path is absolute.
            return path.relative(process.cwd(), info.resourcePath).replace(/^[\/\.]*/, '');
        },
    },
    resolve: {
        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.
            "react": path.resolve('./node_modules/react'),
            "react-dom": path.resolve('./node_modules/react-dom'),
            "react-addons-perf": path.resolve('./node_modules/react-addons-perf'),

            // same goes for js-sdk
            "matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),
        },
    },
    externals: {
        "olm": "Olm",
        // Don't try to bundle electron: leave it as a commonjs dependency
        // (the 'commonjs' here means it will output a 'require')
        "electron": "commonjs electron",
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify(process.env.NODE_ENV),
            },
        }),

        new ExtractTextPlugin("bundles/[hash]/[name].css", {
            allChunks: true,
        }),

        new HtmlWebpackPlugin({
            template: './src/vector/index.html',

            // we inject the links ourselves via the template, because
            // HtmlWebpackPlugin wants to put the script tags either at the
            // bottom of <head> or the bottom of <body>, and I'm a bit scared
            // about moving them.
            inject: false,
        }),
    ],
    devtool: 'source-map',

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

        stats: {
            // don't fill the console up with a mahoosive list of modules
            chunks: false,
        },
    },
};

// olm is an optional dependency. Ignore it if it's not installed, to avoid a
// scary-looking error.
try {
    require('olm');
} catch (e) {
    console.log("Olm is not installed; not shipping it");
    delete(module.exports.entry["olm"]);
}
<|endoftext|>


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

module.exports = {
  entry: './index.js',

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

  output: {
    path: path.join(process.cwd(), 'dist'),
    filename: 'index.js'
  },

  externals: {
    react: "React"
  },

  module: {
    loaders: [
      {test: /\.jsx$/, loader: 'jsx-loader?harmony'},
      {test: /\.js$/, loader: 'jsx-loader?harmony'},
      {test: /\.json$/, loader: 'json-loader'},
      {test: /\.less$/, loader: "style!css!less"},
      {test: /\.css/, loader: 'style!css'}
    ]
  },

  devtool: "#source-map"
};
<commit_msg>jsx-loader -> babel-loader in webpack.config, #5<commit_after>var webpack = require('webpack');
var path = require('path');

module.exports = {
  entry: './index.js',

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

  output: {
    path: path.join(process.cwd(), 'dist'),
    filename: 'index.js'
  },

  externals: {
    react: "React"
  },

  module: {
    loaders: [
      {test: /\.jsx?$/, loader: 'babel'},
      {test: /\.json$/, loader: 'json-loader'},
      {test: /\.less$/, loader: "style!css!less"},
      {test: /\.css/, loader: 'style!css'}
    ]
  },

  devtool: "#source-map"
};
<|endoftext|>


<commit_before>var webpack = require('webpack');
module.exports = {
    entry: [
      'webpack/hot/only-dev-server',
      "./js/app.js",
      "./scss/style.scss"
    ],
    output: {
        path: __dirname + '/build',
        filename: "bundle.js"
    },
    module: {
        preLoaders: [
          {
            test: /(\.js$|\.jsx$)/,
            exclude: /node_modules/,
            loader: "eslint-loader"
          }
        ],
        loaders: [
            { test: /\.jsx?$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/ },
            { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
            { test: /\.scss$/, loader: "style!css!sass" }
        ]
    },
    eslint: {
      configFile: '.eslintrc.yml'
    },
    plugins: [
      new webpack.NoErrorsPlugin()
    ]

};
<commit_msg>Amended Webpack config<commit_after>var webpack = require('webpack');
module.exports = {
    entry: [
      "./js/app.js"
    ],
    output: {
        path: __dirname + '/build',
        filename: "bundle.js",
        libraryTarget: 'umd'
    },
    module: {
        loaders: [
            { test: /\.jsx?$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/ },
            { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
            { test: /\.scss$/, loader: "style!css!sass" }
        ]
    },
    plugins: [
      new webpack.NoErrorsPlugin()
    ]

};
<|endoftext|>


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

module.exports = {
    entry: [
        './src/js/redraw.js',
        './src/js/tools/arrow.js',
        './src/js/tools/box.js',
        './src/js/tools/pixelate.js',
        './src/js/tools/clear-tool.js',
        './src/js/tools/horizontal-line-tool.js',
        './src/js/tools/remove-tool.js',
        './src/js/tools/text.js'
        ],
    output: {
        path: __dirname,
        filename: './dist/redraw.js'
    },
    plugins: [
        new webpack.dependencies.LabeledModulesPlugin()
    ],
    resolve: {
        modulesDirectories: ['bower_components', 'node_modules']
    },
    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: "style!css"
            },
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/
            },
            { test: /\.json$/, loader: "json" }
        ]
    }
};<commit_msg>Uncomment to minify<commit_after>var webpack = require('webpack');
var path = require('path');

module.exports = {
    entry: [
        './src/js/redraw.js',
        './src/js/tools/arrow.js',
        './src/js/tools/box.js',
        './src/js/tools/pixelate.js',
        './src/js/tools/clear-tool.js',
        './src/js/tools/horizontal-line-tool.js',
        './src/js/tools/remove-tool.js',
        './src/js/tools/text.js'
        ],
    output: {
        path: __dirname,
        filename: './dist/redraw.js'
    },
    plugins: [
        new webpack.dependencies.LabeledModulesPlugin()/*,
        new webpack.optimize.UglifyJsPlugin({minimize: true})*/
    ],

    resolve: {
        modulesDirectories: ['bower_components', 'node_modules']
    },
    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: "style!css"
            },
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/
            },
            { test: /\.json$/, loader: "json" }
        ]
    }
};<|endoftext|>


<commit_before>const path = require("path")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const ManifestPlugin = require("webpack-manifest-plugin")
const MomentLocalesPlugin = require("moment-locales-webpack-plugin")
const Dotenv = require("dotenv-webpack")

const TerserJSPlugin = require("terser-webpack-plugin")
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin")
const { EnvironmentPlugin } = require("webpack")

module.exports = (env, argv) => {
    const isProduction = argv.mode === "production"
    return {
        context: __dirname,
        entry: {
            admin: "./admin/client/admin.entry.ts",
            owid: "./site/client/owid.entry.ts"
        },
        optimization: {
            splitChunks: {
                cacheGroups: {
                    commons: {
                        name: "commons",
                        chunks: "all",
                        minChunks: 2
                    }
                }
            },
            minimize: isProduction,
            minimizer: [new TerserJSPlugin(), new OptimizeCSSAssetsPlugin()]
        },
        output: {
            path: path.join(__dirname, "dist/webpack"),
            filename: "js/[name].js"
            //filename: (isProduction ? "js/[name].bundle.[hash].js" : "js/[name].js")
        },
        resolve: {
            extensions: [".ts", ".tsx", ".js", ".css"],
            modules: [path.join(__dirname, "node_modules"), __dirname]
        },
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    loader: "ts-loader",
                    exclude: /serverSettings/,
                    options: {
                        transpileOnly: true,
                        configFile: path.join(__dirname, "tsconfig.client.json")
                    }
                },
                {
                    test: /\.s?css$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        "css-loader",
                        "postcss-loader",
                        {
                            loader: "sass-loader",
                            options: {
                                outputStyle: "expanded" // Needed so autoprefixer comments are included
                            }
                        }
                    ]
                },
                {
                    test: /\.(jpe?g|gif|png|eot|woff|ttf|svg|woff2)$/,
                    loader: "url-loader",
                    options: {
                        limit: 10000,
                        useRelativePaths: true,
                        publicPath: "../"
                    }
                }
            ]
        },
        plugins: [
            // This plugin extracts css files required in the entry points
            // into a separate CSS bundle for download
            new MiniCssExtractPlugin({ filename: "css/[name].css" }),

            // Writes manifest.json which production code reads to know paths to asset files
            new ManifestPlugin(),

            // Remove all moment locales except for "en"
            // This way of doing so is recommended by Moment itself: https://momentjs.com/docs/#/use-it/webpack/
            new MomentLocalesPlugin(),

            // This plugin loads settings from .env so we can import them
            // Note that this means the settings become part of the client-side JS at webpack build time, not at server run time
            new Dotenv(),

            // This plugin will convert any mentions of "process.env.DATA_TABLE" in the codebase into value of that
            // environment variable at compile-time, or null as default.
            new EnvironmentPlugin({ DATA_TABLE: null })
        ],
        devServer: {
            host: "localhost",
            port: 8090,
            contentBase: "public",
            disableHostCheck: true,
            headers: {
                "Access-Control-Allow-Origin": "*",
                "Access-Control-Allow-Methods":
                    "GET, POST, PUT, DELETE, PATCH, OPTIONS",
                "Access-Control-Allow-Headers":
                    "X-Requested-With, content-type, Authorization"
            }
        }
    }
}
<commit_msg>fix: remove extra EnvironmentPlugin<commit_after>const path = require("path")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const ManifestPlugin = require("webpack-manifest-plugin")
const MomentLocalesPlugin = require("moment-locales-webpack-plugin")
const Dotenv = require("dotenv-webpack")

const TerserJSPlugin = require("terser-webpack-plugin")
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin")

module.exports = (env, argv) => {
    const isProduction = argv.mode === "production"
    return {
        context: __dirname,
        entry: {
            admin: "./admin/client/admin.entry.ts",
            owid: "./site/client/owid.entry.ts"
        },
        optimization: {
            splitChunks: {
                cacheGroups: {
                    commons: {
                        name: "commons",
                        chunks: "all",
                        minChunks: 2
                    }
                }
            },
            minimize: isProduction,
            minimizer: [new TerserJSPlugin(), new OptimizeCSSAssetsPlugin()]
        },
        output: {
            path: path.join(__dirname, "dist/webpack"),
            filename: "js/[name].js"
            //filename: (isProduction ? "js/[name].bundle.[hash].js" : "js/[name].js")
        },
        resolve: {
            extensions: [".ts", ".tsx", ".js", ".css"],
            modules: [path.join(__dirname, "node_modules"), __dirname]
        },
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    loader: "ts-loader",
                    exclude: /serverSettings/,
                    options: {
                        transpileOnly: true,
                        configFile: path.join(__dirname, "tsconfig.client.json")
                    }
                },
                {
                    test: /\.s?css$/,
                    use: [
                        MiniCssExtractPlugin.loader,
                        "css-loader",
                        "postcss-loader",
                        {
                            loader: "sass-loader",
                            options: {
                                outputStyle: "expanded" // Needed so autoprefixer comments are included
                            }
                        }
                    ]
                },
                {
                    test: /\.(jpe?g|gif|png|eot|woff|ttf|svg|woff2)$/,
                    loader: "url-loader",
                    options: {
                        limit: 10000,
                        useRelativePaths: true,
                        publicPath: "../"
                    }
                }
            ]
        },
        plugins: [
            // This plugin extracts css files required in the entry points
            // into a separate CSS bundle for download
            new MiniCssExtractPlugin({ filename: "css/[name].css" }),

            // Writes manifest.json which production code reads to know paths to asset files
            new ManifestPlugin(),

            // Remove all moment locales except for "en"
            // This way of doing so is recommended by Moment itself: https://momentjs.com/docs/#/use-it/webpack/
            new MomentLocalesPlugin(),

            // This plugin loads settings from .env so we can import them
            // Note that this means the settings become part of the client-side JS at webpack build time, not at server run time
            new Dotenv()
        ],
        devServer: {
            host: "localhost",
            port: 8090,
            contentBase: "public",
            disableHostCheck: true,
            headers: {
                "Access-Control-Allow-Origin": "*",
                "Access-Control-Allow-Methods":
                    "GET, POST, PUT, DELETE, PATCH, OPTIONS",
                "Access-Control-Allow-Headers":
                    "X-Requested-With, content-type, Authorization"
            }
        }
    }
}
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
// var BrowserSyncPlugin = require('browser-sync-webpack-plugin');

// Phaser webpack config
var phaserModule = path.join(__dirname, '/node_modules/phaser-ce/');
var phaser = path.join(phaserModule, 'build/custom/phaser-split.js');
var pixi = path.join(phaserModule, 'build/custom/pixi.js');
var p2 = path.join(phaserModule, 'build/custom/p2.js');

// var tilemapWalker = path.join(__dirname, '/plugins/TilemapWalker');
// var phasetips = path.join(__dirname, '/plugins/Phasetips');

var definePlugin = new webpack.DefinePlugin({
  __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true'))
})

module.exports = {
  entry: {
    app: [
      'babel-polyfill',
      path.resolve(__dirname, 'src/main.js')
    ],
    vendor: [
      'pixi',
      'p2',
      'phaser',
      // 'tilemap-walker',
      // 'phasetips',
    ],
  },
  devtool: 'cheap-source-map',
  output: {
    pathinfo: true,
    path: path.resolve(__dirname, 'dist'),
    publicPath: './dist/',
    filename: 'bundle.js',
  },
  watch: true,
  plugins: [
    definePlugin,
    new webpack.optimize.CommonsChunkPlugin({ name: 'vendor'/* chunkName= */, filename: 'vendor.bundle.js'/* filename= */}),
    // new BrowserSyncPlugin({
    //   host: process.env.IP || 'localhost',
    //   port: process.env.PORT || 3000,
    //   server: {
    //     baseDir: ['./', './build']
    //   }
    // }),
  ],
  module: {
    rules: [
      { test: /\.js$/, use: ['babel-loader'], include: path.join(__dirname, 'src') },
      { test: /pixi\.js/, use: ['expose-loader?PIXI'] },
      { test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] },
      { test: /p2\.js/, use: ['expose-loader?p2'] },
    ],
  },
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
  },
  resolve: {
    alias: {
      'phaser': phaser,
      'pixi': pixi,
      'p2': p2,
      // 'tilemap-walker': tilemapWalker,
      // 'phasetips': phasetips,
    }
  }
};
<commit_msg>Add options to webpack file<commit_after>const options = {
  watch: true,
  quick: false,
};

var path = require('path');
var webpack = require('webpack');
// var BrowserSyncPlugin = require('browser-sync-webpack-plugin');

// Phaser webpack config
var phaserModule = path.join(__dirname, '/node_modules/phaser-ce/');
var phaser = path.join(phaserModule, 'build/custom/phaser-split.js');
var pixi = path.join(phaserModule, 'build/custom/pixi.js');
var p2 = path.join(phaserModule, 'build/custom/p2.js');

// var tilemapWalker = path.join(__dirname, '/plugins/TilemapWalker');
// var phasetips = path.join(__dirname, '/plugins/Phasetips');

var definePlugin = new webpack.DefinePlugin({
  __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true'))
});

const config = {
  entry: {
    app: [
      path.resolve(__dirname, 'src/main.js')
    ],
    vendor: [
      'pixi',
      'p2',
      'phaser',
      // 'tilemap-walker',
      // 'phasetips',
    ],
  },
  devtool: 'cheap-source-map',
  output: {
    pathinfo: true,
    path: path.resolve(__dirname, 'dist'),
    publicPath: './dist/',
    filename: 'bundle.js',
  },
  watch: options.watch,
  plugins: [
    definePlugin,
    new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js'}),
    // new BrowserSyncPlugin({
    //   host: process.env.IP || 'localhost',
    //   port: process.env.PORT || 3000,
    //   server: {
    //     baseDir: ['./', './build']
    //   }
    // }),
  ],
  module: {
    rules: [
      { test: /pixi\.js/, use: ['expose-loader?PIXI'] },
      { test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] },
      { test: /p2\.js/, use: ['expose-loader?p2'] },
    ],
  },
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
  },
  resolve: {
    alias: {
      'phaser': phaser,
      'pixi': pixi,
      'p2': p2,
      // 'tilemap-walker': tilemapWalker,
      // 'phasetips': phasetips,
    }
  }
};

if (options.quick) {
  delete config.devtool;
} else {
  config.entry.app.push(
    'babel-polyfill'
  );
  config.module.rules.push(
    { test: /\.js$/, use: ['babel-loader'], include: path.join(__dirname, 'src') }
  );
}

module.exports = config;
<|endoftext|>


<commit_before>/* eslint-env node, es6 */

const merge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');

const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');

// Shared configuration.
const commonConfig = {
  context: path.resolve(__dirname, './src'),
  entry: './main.js',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'js/bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: 'babel-loader',
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          use: ['css-loader', 'postcss-loader'],
        }),
      },
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract({
          use: ['css-loader', 'postcss-loader', 'sass-loader'],
        }),
      },
      {
        test: /\.(ttf|eot|woff|woff2)$/,
        loader: 'file-loader',
        options: {
          name: 'fonts/[name].[ext]',
        },
      },
      {
        test: /\.(jpg|png|svg)$/,
        loader: 'file-loader',
        options: {
          name: 'graphics/[hash].[ext]',
        },
      },
    ],
  },
  plugins: [
    new ExtractTextPlugin('css/[name].css'),
  ],
};

// Development configuration.
const developmentConfig = {
  devtool: 'cheap-eval-source-map',
  watch: true,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('development'),
    }),
    new BrowserSyncPlugin({
      host: 'localhost',
      port: 3000,
      proxy: 'drupal-reference.dev',
    }),
    new StyleLintPlugin({
      context: path.resolve(__dirname, '../src/scss'),
    }),
  ],
};

// Production configuration.
const productionConfig = {
  devtool: 'source-map',
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false,
    }),
    new webpack.optimize.UglifyJsPlugin({}),
  ],
};

// Export config based on the current environment.
if (process.env.NODE_ENV === 'production') {
  module.exports = merge(commonConfig, productionConfig);
} else {
  module.exports = merge(commonConfig, developmentConfig);
}
<commit_msg>Fixed css exports<commit_after>/* eslint-env node, es6 */

const merge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');

const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');

const ExtractMainSass = new ExtractTextPlugin('css/main.css');
const ExtractCkeditorSass = new ExtractTextPlugin('css/ckeditor.css');
const ExtractPrintSass = new ExtractTextPlugin('css/print.css');

// Shared configuration.
const commonConfig = {
  context: path.resolve(__dirname, './src'),
  entry: './main.js',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'js/bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: 'babel-loader',
      },
      {
        test: /\.css$/,
        use: 'css-loader',
      },
      {
        test: /ckeditor\.scss$/,
        use: ExtractCkeditorSass.extract({
          use: ['css-loader', 'postcss-loader', 'sass-loader'],
        }),
      },
      {
        test: /main\.scss$/,
        use: ExtractMainSass.extract({
          use: ['css-loader', 'postcss-loader', 'sass-loader'],
        }),
      },
      {
        test: /print\.scss$/,
        use: ExtractPrintSass.extract({
          use: ['css-loader', 'postcss-loader', 'sass-loader'],
        }),
      },
      {
        test: /\.(ttf|eot|woff|woff2)$/,
        loader: 'file-loader',
        options: {
          name: 'fonts/[name].[ext]',
        },
      },
      {
        test: /\.(jpg|png|svg)$/,
        loader: 'file-loader',
        options: {
          name: 'graphics/[hash].[ext]',
        },
      },
    ],
  },
  plugins: [
    ExtractCkeditorSass,
    ExtractMainSass,
    ExtractPrintSass,
  ],
};

// Development configuration.
const developmentConfig = {
  devtool: 'cheap-eval-source-map',
  watch: true,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('development'),
    }),
    new BrowserSyncPlugin({
      host: 'localhost',
      port: 3000,
      proxy: 'drupal-reference.dev',
    }),
    new StyleLintPlugin({
      context: path.resolve(__dirname, './src/scss'),
    }),
  ],
};

// Production configuration.
const productionConfig = {
  devtool: 'source-map',
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true,
      debug: false,
    }),
    new webpack.optimize.UglifyJsPlugin({}),
  ],
};

// Export config based on the current environment.
if (process.env.NODE_ENV === 'production') {
  module.exports = merge(commonConfig, productionConfig);
} else {
  module.exports = merge(commonConfig, developmentConfig);
}
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OfflinePlugin = require('offline-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const includes = [path.join(__dirname, 'src'), path.join(__dirname, 'res')];

const es6modules = ['pretty-bytes'];
const es6modulePaths = es6modules.map(module => {
  return path.join(__dirname, 'node_modules', module);
});

const config = {
  resolve: {
    alias: {
      'redux-devtools/lib': path.join(__dirname, '..', '..', 'src'),
      'redux-devtools': path.join(__dirname, '..', '..', 'src'),
      react: path.join(__dirname, 'node_modules', 'react'),
    },
    extensions: ['.js'],
  },
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js$/,
        loaders: ['babel-loader'],
        include: includes.concat(es6modulePaths),
      },
      {
        test: /\.json$/,
        loaders: ['json-loader'],
        include: includes,
      },
      {
        test: /\.css?$/,
        loaders: ['style-loader', 'css-loader?minimize'],
        include: includes.concat(
          path.join(__dirname, 'node_modules', 'photon-colors')
        ),
      },
      {
        test: /\.jpg$/,
        loader: 'file-loader',
      },
      {
        test: /\.png$/,
        loader: 'file-loader',
      },
      {
        test: /\.svg$/,
        loader: 'file-loader',
      },
    ],
  },
  node: {
    process: false,
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
    }),
    new webpack.optimize.ModuleConcatenationPlugin(),
    new HtmlWebpackPlugin({
      title: 'perf.html',
      template: 'res/index.html',
      favicon: 'res/favicon.png',
    }),
  ],
  entry: ['./src/index'],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[hash].bundle.js',
    chunkFilename: '[id].[hash].bundle.js',
    publicPath: '/',
  },
};

if (process.env.NODE_ENV === 'development') {
  config.devtool = 'source-map';
  config.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(
    config.entry
  );
}

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(
    new UglifyJsPlugin({
      sourceMap: true,
      parallel: true,
      cache: true,
      uglifyOptions: process.env.UGLIFY_OPTIONS
        ? JSON.parse(process.env.UGLIFY_OPTIONS)
        : undefined,
    }),
    new OfflinePlugin({
      relativePaths: false,
      AppCache: false,
      ServiceWorker: {
        scope: '/',
        events: true,
      },
      externals: ['/zee-worker.js', '/worker.js', '/analytics.js'],
      cacheMaps: [
        {
          requestTypes: null,
          match: function(url, _request) {
            return url.origin === location.origin ? url.origin + '/' : null;
          },
        },
      ],
    })
  );
}

module.exports = config;
<commit_msg>Disable ModuleConcatenationPlugin in development mode so that Hot Module Reloading works<commit_after>const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OfflinePlugin = require('offline-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const includes = [path.join(__dirname, 'src'), path.join(__dirname, 'res')];

const es6modules = ['pretty-bytes'];
const es6modulePaths = es6modules.map(module => {
  return path.join(__dirname, 'node_modules', module);
});

const config = {
  resolve: {
    alias: {
      'redux-devtools/lib': path.join(__dirname, '..', '..', 'src'),
      'redux-devtools': path.join(__dirname, '..', '..', 'src'),
      react: path.join(__dirname, 'node_modules', 'react'),
    },
    extensions: ['.js'],
  },
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js$/,
        loaders: ['babel-loader'],
        include: includes.concat(es6modulePaths),
      },
      {
        test: /\.json$/,
        loaders: ['json-loader'],
        include: includes,
      },
      {
        test: /\.css?$/,
        loaders: ['style-loader', 'css-loader?minimize'],
        include: includes.concat(
          path.join(__dirname, 'node_modules', 'photon-colors')
        ),
      },
      {
        test: /\.jpg$/,
        loader: 'file-loader',
      },
      {
        test: /\.png$/,
        loader: 'file-loader',
      },
      {
        test: /\.svg$/,
        loader: 'file-loader',
      },
    ],
  },
  node: {
    process: false,
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
    }),
    new HtmlWebpackPlugin({
      title: 'perf.html',
      template: 'res/index.html',
      favicon: 'res/favicon.png',
    }),
  ],
  entry: ['./src/index'],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[hash].bundle.js',
    chunkFilename: '[id].[hash].bundle.js',
    publicPath: '/',
  },
};

if (process.env.NODE_ENV === 'development') {
  config.devtool = 'source-map';
  config.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(
    config.entry
  );
}

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(
    new webpack.optimize.ModuleConcatenationPlugin(),
    new UglifyJsPlugin({
      sourceMap: true,
      parallel: true,
      cache: true,
      uglifyOptions: process.env.UGLIFY_OPTIONS
        ? JSON.parse(process.env.UGLIFY_OPTIONS)
        : undefined,
    }),
    new OfflinePlugin({
      relativePaths: false,
      AppCache: false,
      ServiceWorker: {
        scope: '/',
        events: true,
      },
      externals: ['/zee-worker.js', '/worker.js', '/analytics.js'],
      cacheMaps: [
        {
          requestTypes: null,
          match: function(url, _request) {
            return url.origin === location.origin ? url.origin + '/' : null;
          },
        },
      ],
    })
  );
}

module.exports = config;
<|endoftext|>


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

module.exports = {
  entry: {
    app: [ "./app/js/app.jsx" ]
  },
  output: {
    path: path.join(__dirname, 'build'),
    filename: "js/[name].js"
  },
  module: {
    loaders: [
      { test: /\.jsx?$/,                   loader: 'jsx?harmony', exclude: /node_modules/ },
      { test: /\.json$/,                   loader: 'json' },

      { test: /\.css$/,                    loader: ExtractTextPlugin.extract('style', 'css') },
      { test: /\.less$/,                   loader: ExtractTextPlugin.extract('style', 'css!less') },

      { test: /\.(png|jpg|jpeg|gif)$/,     loader: 'url-loader?limit=10000&name=images/[name].[ext]' },
      { test: /\.(woff|woff2)$/,           loader: 'url-loader?limit=10000&name=fonts/[name].[ext]' },
      { test: /\.(ttf|eot|svg)$/,          loader: 'file-loader?name=fonts/[name].[ext]' }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  plugins: [
    new ExtractTextPlugin("css/[name].css", {
      allChunks: true
    }),
    new HtmlWebpackPlugin({
      template: './app/index.html',
      inject: true
    })
  ]
};
<commit_msg>long time cache<commit_after>var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  entry: {
    app: [ "./app/js/app.jsx" ]
  },
  output: {
    path: path.join(__dirname, 'build'),
    filename: "js/[name]-[chunkhash].js",
    chunkFilename: "js/[id]-[chunkhash].js"
  },
  module: {
    loaders: [
      { test: /\.jsx?$/,                   loader: 'jsx?harmony', exclude: /node_modules/ },
      { test: /\.json$/,                   loader: 'json' },

      { test: /\.css$/,                    loader: ExtractTextPlugin.extract('style', 'css') },
      { test: /\.less$/,                   loader: ExtractTextPlugin.extract('style', 'css!less') },

      { test: /\.(png|jpg|jpeg|gif)$/,     loader: 'url-loader?limit=10000&name=images/[name].[ext]' },
      { test: /\.(woff|woff2)$/,           loader: 'url-loader?limit=10000&name=fonts/[name].[ext]' },
      { test: /\.(ttf|eot|svg)$/,          loader: 'file-loader?name=fonts/[name].[ext]' }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  plugins: [
    new ExtractTextPlugin("css/[name]-[contenthash].css", {
      allChunks: true
    }),
    new HtmlWebpackPlugin({
      template: './app/index.html',
      inject: true
    })
  ]
};
<|endoftext|>


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

module.exports = {
  entry: './src/kuzzle.js',
  output: {
    path: './dist',
    filename: 'kuzzle.js',
		library: 'Kuzzle',
    libraryTarget: 'umd'
  },
  watch: false,
  debug: false,
  devtool: 'source-map',
  node: {
    console: false,
    global: false,
    process: false,
    Buffer: false,
    __filename: false,
    __dirname: false,
    setImmediate: false
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'eslint-loader',
        include: path.resolve(__dirname, './src/'),
        exclude: /node_modules/
      }
    ]
  },
  eslint: {
    formatter: require('eslint-friendly-formatter')
  },
  plugins: [
    new webpack.NoErrorsPlugin(),
    new webpack.IgnorePlugin(/ws/),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      global: 'window'
    }),
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false
      }
    })
  ]
};
<commit_msg>syntax<commit_after>var webpack = require('webpack');
var path = require('path');

module.exports = {
  entry: './src/kuzzle.js',
  output: {
    path: './dist',
    filename: 'kuzzle.js',
    library: 'Kuzzle',
    libraryTarget: 'umd'
  },
  watch: false,
  debug: false,
  devtool: 'source-map',
  node: {
    console: false,
    global: false,
    process: false,
    Buffer: false,
    __filename: false,
    __dirname: false,
    setImmediate: false
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'eslint-loader',
        include: path.resolve(__dirname, './src/'),
        exclude: /node_modules/
      }
    ]
  },
  eslint: {
    formatter: require('eslint-friendly-formatter')
  },
  plugins: [
    new webpack.NoErrorsPlugin(),
    new webpack.IgnorePlugin(/ws/),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      global: 'window'
    }),
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false
      }
    })
  ]
};
<|endoftext|>


<commit_before>var path    = require('path');
var webpack = require('webpack');
var cwd     = process.cwd();

module.exports = {
  entry: {
    'admin': './client/javascripts/admin/admin.jsx',
    'users': './client/javascripts/users/users.jsx',
    'users-authenticate': './client/javascripts/users/users-authenticate.jsx',
    'users-show': './client/javascripts/users/users-show.jsx',
    'articles': './client/javascripts/articles/articles.jsx',
  },
  output: {
    path: path.join(__dirname, 'public/assets/javascripts'),
    publicPath: 'public/assets/javascripts',
    filename: '[name].js',
  },
  resolve: {
    extensions: ['', '.js', '.jsx', '.css', '.scss'],
    root: [
      path.join(__dirname, 'client/javascripts'),
      path.join(__dirname, 'client/stylesheets'),
    ],
    modulesDirectories: ['node_modules'],
  },
  module: {
    loaders: [
      { test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel' },
      { test: /\.css$/, loader: 'css' },
      { test: /\.scss$/, loader: 'scss' },
    ],
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin()
  ]
};
<commit_msg>close #14, NODE_ENV=production gulp build<commit_after>var path    = require('path');
var webpack = require('webpack');
var cwd     = process.cwd();

module.exports = {
  entry: {
    'admin': './client/javascripts/admin/admin.jsx',
    'users': './client/javascripts/users/users.jsx',
    'users-authenticate': './client/javascripts/users/users-authenticate.jsx',
    'users-show': './client/javascripts/users/users-show.jsx',
    'articles': './client/javascripts/articles/articles.jsx',
  },
  output: {
    path: path.join(__dirname, 'public/assets/javascripts'),
    publicPath: 'public/assets/javascripts',
    filename: '[name].js',
  },
  resolve: {
    extensions: ['', '.js', '.jsx', '.css', '.scss'],
    root: [
      path.join(__dirname, 'client/javascripts'),
      path.join(__dirname, 'client/stylesheets'),
    ],
    modulesDirectories: ['node_modules'],
  },
  module: {
    loaders: [
      { test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel' },
      { test: /\.css$/, loader: 'css' },
      { test: /\.scss$/, loader: 'scss' },
    ],
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': `"${process.env.NODE_ENV || 'development'}"`,
    }),
    new webpack.optimize.UglifyJsPlugin(),
  ]
};
<|endoftext|>


<commit_before>const webpack = require('webpack');
const config = require('sapper/config/webpack.js');
const pkg = require('./package.json');

const mode = process.env.NODE_ENV;
const dev = mode === 'development';

module.exports = {
	client: {
		entry: config.client.entry(),
		output: Object.assign(config.client.output(), {
			globalObject: 'this'
		}),
		resolve: {
			extensions: ['.js', '.json', '.html'],
			mainFields: ['svelte', 'module', 'browser', 'main']
		},
		module: {
			rules: [
				{
					test: /\.html$/,
					use: {
						loader: 'svelte-loader',
						options: {
							dev,
							hydratable: true,
							hotReload: true
						}
					}
				},
				{
					test: /\.css$/,
					use: [
						'style-loader',
						'css-loader'
					]
				}
			]
		},
		mode,
		plugins: [
			dev && new webpack.HotModuleReplacementPlugin(),
			new webpack.DefinePlugin({
				'process.browser': true,
				'process.env.NODE_ENV': JSON.stringify(mode)
			}),
		].filter(Boolean),
		devtool: dev && 'inline-source-map'
	},

	server: {
		entry: config.server.entry(),
		output: config.server.output(),
		target: 'node',
		resolve: {
			extensions: ['.js', '.json', '.html'],
			mainFields: ['svelte', 'module', 'browser', 'main']
		},
		externals: Object.keys(pkg.dependencies),
		module: {
			rules: [
				{
					test: /\.html$/,
					use: {
						loader: 'svelte-loader',
						options: {
							css: false,
							generate: 'ssr',
							dev
						}
					}
				},
				{
					test: /\.css$/,
					use: [
						'style-loader',
						'css-loader'
					]
				}
			]
		},
		mode: process.env.NODE_ENV,
		performance: {
			hints: false // it doesn't matter if server.js is large
		}
	},

	serviceworker: {
		entry: config.serviceworker.entry(),
		output: config.serviceworker.output(),
		mode: process.env.NODE_ENV
	}
};
<commit_msg>temporary fix to prevent HMR on production (#370)<commit_after>const webpack = require('webpack');
const config = require('sapper/config/webpack.js');
const pkg = require('./package.json');

const mode = process.env.NODE_ENV;
const dev = mode === 'development';

module.exports = {
	client: {
		entry: config.client.entry(),
		output: Object.assign(config.client.output(), {
			globalObject: 'this'
		}),
		resolve: {
			extensions: ['.js', '.json', '.html'],
			mainFields: ['svelte', 'module', 'browser', 'main']
		},
		module: {
			rules: [
				{
					test: /\.html$/,
					use: {
						loader: 'svelte-loader',
						options: {
							dev,
							hydratable: true,
							hotReload: dev,
						}
					}
				},
				{
					test: /\.css$/,
					use: [
						'style-loader',
						'css-loader'
					]
				}
			]
		},
		mode,
		plugins: [
			dev && new webpack.HotModuleReplacementPlugin(),
			new webpack.DefinePlugin({
				'process.browser': true,
				'process.env.NODE_ENV': JSON.stringify(mode)
			}),
		].filter(Boolean),
		devtool: dev && 'inline-source-map'
	},

	server: {
		entry: config.server.entry(),
		output: config.server.output(),
		target: 'node',
		resolve: {
			extensions: ['.js', '.json', '.html'],
			mainFields: ['svelte', 'module', 'browser', 'main']
		},
		externals: Object.keys(pkg.dependencies),
		module: {
			rules: [
				{
					test: /\.html$/,
					use: {
						loader: 'svelte-loader',
						options: {
							css: false,
							generate: 'ssr',
							dev
						}
					}
				},
				{
					test: /\.css$/,
					use: [
						'style-loader',
						'css-loader'
					]
				}
			]
		},
		mode: process.env.NODE_ENV,
		performance: {
			hints: false // it doesn't matter if server.js is large
		}
	},

	serviceworker: {
		entry: config.serviceworker.entry(),
		output: config.serviceworker.output(),
		mode: process.env.NODE_ENV
	}
};
<|endoftext|>


<commit_before>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const webpack = require('webpack');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const validate = require('webpack-validator');

// Load *package.json* so we can use `dependencies` from there
const pkg = require('./package.json');

const PATHS = {
  react: path.join(__dirname, 'node_modules/react/dist/react.min.js'),
  app: path.join(__dirname, 'app'),
  build: path.join(__dirname, 'build'),
  style: path.join(__dirname, 'app/main.css')
};

const common = commonConfiguration(PATHS);
var config;

// Detect how npm is run and branch based on that
switch(process.env.npm_lifecycle_event) {
  case 'build':
  case 'stats':
    config = merge(
      common,
      {
        output: {
          path: PATHS.build,
          filename: '[name].[chunkhash].js',
          chunkFilename: '[chunkhash].js'
        }
      },
      clean(PATHS.build),
      setEnvironment({
        key: 'process.env.NODE_ENV',
        value: 'production'
      }),
      extractBundle({
        name: 'vendor',
        entries: Object.keys(pkg.dependencies)
      }),
      extractCSS(PATHS.app),
      minify()
    );
  case 'start':
  default:
    config = merge(
      common,
      {
        devtool: 'eval-source-map',
        plugins: [
          new webpack.HotModuleReplacementPlugin(),
          new NpmInstallPlugin({
            save: true // --save
          })
        ]
      },
      devServer({
        // Customize host/port here if needed
        host: process.env.HOST,
        port: process.env.PORT
      }),
      setupCSS(PATHS.app),
      dontParse({
        name: 'react',
        path: PATHS.react
      })
    );
}

module.exports = validate(config);

// Configuration fragments, these could be split to multiple
// files if needed.
function commonConfiguration(paths) {
  return {
    // Entry accepts a path or an object of entries.
    // We'll be using the latter form given it's
    // convenient with more complex configurations.
    entry: {
      app: paths.app,
      style: paths.style
    },
    output: {
      path: paths.build,
      // Output using the entry name
      filename: '[name].js'
    },
    plugins: [
      new HtmlWebpackPlugin({
        title: 'Webpack demo'
      })
    ]
  };
}

function setupCSS(path) {
  return {
    module: {
      loaders: [
        {
          test: /\.css$/,
          loaders: ['style', 'css'],
          include: path
        }
      ]
    }
  };
}

function devServer(options) {
  return {
    devServer: {
      // Enable history API fallback so HTML5 History API based
      // routing works. This is a good default that will come
      // in handy in more complicated setups.
      historyApiFallback: true,
      hot: true,
      inline: true,
      progress: true,

      // Display only errors to reduce the amount of output.
      stats: 'errors-only',

      // Parse host and port from env to allow customization.
      //
      // If you use Vagrant or Cloud9, set
      // host: process.env.HOST || '0.0.0.0';
      //
      // 0.0.0.0 is available to all network devices
      // unlike default localhost
      host: options.host,
      port: options.port
    },
  };
}

function dontParse(options) {
  const alias = {};
  alias[options.name] = options.path;

  return {
    module: {
      noParse: [
        options.path
      ]
    },
    resolve: {
      alias: alias
    }
  };
}

function setEnvironment(options) {
  const env = {};
  env[options.key] = JSON.stringify(options.value);

  return {
    plugins: [
      new webpack.DefinePlugin(env)
    ]
  };
}

function extractCSS(path) {
  return {
    module: {
      loaders: [
        // Extract CSS during build
        {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract('style', 'css'),
          include: path
        }
      ]
    },
    plugins: [
      // Output extracted CSS to a file
      new ExtractTextPlugin('[name].[chunkhash].css')
    ]
  };
}

function extractBundle(options) {
  const entry = {};
  entry[options.name] = options.entries;

  return {
    // Define vendor entry point needed for splitting.
    entry: entry,
    plugins: [
      // Extract bundle and manifest files. Manifest is
      // needed for reliable caching.
      new webpack.optimize.CommonsChunkPlugin({
        names: [options.name, 'manifest']
      })
    ]
  };
}

function clean(path) {
  return {
    plugins: [
      new CleanWebpackPlugin([path])
    ]
  };
}

function minify() {
  return {
    plugins: [
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false
        }
      })
    ]
  };
}
<commit_msg>Push common configuration higher<commit_after>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const webpack = require('webpack');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const validate = require('webpack-validator');

// Load *package.json* so we can use `dependencies` from there
const pkg = require('./package.json');

const PATHS = {
  react: path.join(__dirname, 'node_modules/react/dist/react.min.js'),
  app: path.join(__dirname, 'app'),
  build: path.join(__dirname, 'build'),
  style: path.join(__dirname, 'app/main.css')
};

const common = {
  // Entry accepts a path or an object of entries.
  // We'll be using the latter form given it's
  // convenient with more complex configurations.
  entry: {
    app: PATHS.app,
    style: PATHS.style
  },
  output: {
    path: PATHS.build,
    // Output using the entry name
    filename: '[name].js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Webpack demo'
    })
  ]
};
var config;

// Detect how npm is run and branch based on that
switch(process.env.npm_lifecycle_event) {
  case 'build':
  case 'stats':
    config = merge(
      common,
      {
        output: {
          path: PATHS.build,
          filename: '[name].[chunkhash].js',
          chunkFilename: '[chunkhash].js'
        }
      },
      clean(PATHS.build),
      setEnvironment({
        key: 'process.env.NODE_ENV',
        value: 'production'
      }),
      extractBundle({
        name: 'vendor',
        entries: Object.keys(pkg.dependencies)
      }),
      extractCSS(PATHS.app),
      minify()
    );
  case 'start':
  default:
    config = merge(
      common,
      {
        devtool: 'eval-source-map',
        plugins: [
          new webpack.HotModuleReplacementPlugin(),
          new NpmInstallPlugin({
            save: true // --save
          })
        ]
      },
      devServer({
        // Customize host/port here if needed
        host: process.env.HOST,
        port: process.env.PORT
      }),
      setupCSS(PATHS.app),
      dontParse({
        name: 'react',
        path: PATHS.react
      })
    );
}

module.exports = validate(config);

function setupCSS(path) {
  return {
    module: {
      loaders: [
        {
          test: /\.css$/,
          loaders: ['style', 'css'],
          include: path
        }
      ]
    }
  };
}

function devServer(options) {
  return {
    devServer: {
      // Enable history API fallback so HTML5 History API based
      // routing works. This is a good default that will come
      // in handy in more complicated setups.
      historyApiFallback: true,
      hot: true,
      inline: true,
      progress: true,

      // Display only errors to reduce the amount of output.
      stats: 'errors-only',

      // Parse host and port from env to allow customization.
      //
      // If you use Vagrant or Cloud9, set
      // host: process.env.HOST || '0.0.0.0';
      //
      // 0.0.0.0 is available to all network devices
      // unlike default localhost
      host: options.host,
      port: options.port
    },
  };
}

function dontParse(options) {
  const alias = {};
  alias[options.name] = options.path;

  return {
    module: {
      noParse: [
        options.path
      ]
    },
    resolve: {
      alias: alias
    }
  };
}

function setEnvironment(options) {
  const env = {};
  env[options.key] = JSON.stringify(options.value);

  return {
    plugins: [
      new webpack.DefinePlugin(env)
    ]
  };
}

function extractCSS(path) {
  return {
    module: {
      loaders: [
        // Extract CSS during build
        {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract('style', 'css'),
          include: path
        }
      ]
    },
    plugins: [
      // Output extracted CSS to a file
      new ExtractTextPlugin('[name].[chunkhash].css')
    ]
  };
}

function extractBundle(options) {
  const entry = {};
  entry[options.name] = options.entries;

  return {
    // Define vendor entry point needed for splitting.
    entry: entry,
    plugins: [
      // Extract bundle and manifest files. Manifest is
      // needed for reliable caching.
      new webpack.optimize.CommonsChunkPlugin({
        names: [options.name, 'manifest']
      })
    ]
  };
}

function clean(path) {
  return {
    plugins: [
      new CleanWebpackPlugin([path])
    ]
  };
}

function minify() {
  return {
    plugins: [
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false
        }
      })
    ]
  };
}
<|endoftext|>


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

const ROOT_PATH = path.resolve(__dirname);

const webpackConfiguration = {
  devtool: 'source-map',
  entry: [
    'bootstrap-loader',
    'tether',
    path.resolve(ROOT_PATH, 'src/main.js')
  ],
  module: {
    preLoaders: [{
      test: /\.jsx?$/,
      loaders: ['eslint'],
      include: path.resolve(ROOT_PATH, 'src')
    }],
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel'
    },
      {
        test: /\.css$/,
        loaders: ['style', 'css', 'postcss']
      },
      {
        test: /\.scss$/,
        loaders: ['style', 'css', 'postcss', 'sass']
      },
      {
        test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: 'url?limit=10000'
      },
      {
        test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
        loader: 'file'
      },
      { test: /bootstrap-sass\/assets\/javascripts\//,
        loader: 'imports?jQuery=jquery'
      }],
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  sassResources: './src/assets/App.scss',
  postcss: [autoprefixer],
  output: {
    path: path.resolve(ROOT_PATH, 'dist'),
    publicPath: '/',
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.ProvidePlugin({
      'window.Tether': 'tether'
    }),
    new HtmlWebpackPlugin({
      template: 'index.html'
    })
  ]
};

if (process.env.NODE_ENV === 'development') {
  webpackConfiguration.module.preLoaders = [
    {
      test: /\.jsx?$/,
      loaders: ['eslint'],
      include: path.resolve(ROOT_PATH, 'src')
    }];
  const webpackHMR = new webpack.HotModuleReplacementPlugin();
  webpackConfiguration.plugins.push(webpackHMR);
  webpackConfiguration.entry.push('webpack-hot-middleware/client');
}

if (process.env.NODE_ENV === 'production') {
  const webpackNoErrors = new webpack.NoErrorsPlugin();
  const webpackUglify = new webpack.optimize.UglifyJsPlugin({
    noerr: true
  });
  webpackConfiguration.plugins.push(
    webpackUglify,
    webpackNoErrors
  );
}

module.exports = webpackConfiguration;
<commit_msg>[refactor] update webpack for faster development rebuilds<commit_after>const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');

const ROOT_PATH = path.resolve(__dirname);

const webpackConfiguration = {
  devtool: 'eval',
  entry: [
    'bootstrap-loader',
    'tether',
    path.resolve(ROOT_PATH, 'src/main.js')
  ],
  module: {
    preLoaders: [{
      test: /\.jsx?$/,
      loaders: ['eslint'],
      include: path.resolve(ROOT_PATH, 'src')
    }],
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel'
    },
      {
        test: /\.css$/,
        loaders: ['style', 'css', 'postcss']
      },
      {
        test: /\.scss$/,
        loaders: ['style', 'css', 'postcss', 'sass']
      },
      {
        test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: 'url?limit=10000'
      },
      {
        test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
        loader: 'file'
      },
      { test: /bootstrap-sass\/assets\/javascripts\//,
        loader: 'imports?jQuery=jquery'
      }],
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  sassResources: './src/assets/App.scss',
  postcss: [autoprefixer],
  output: {
    path: path.resolve(ROOT_PATH, 'dist'),
    publicPath: '/',
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.ProvidePlugin({
      'window.Tether': 'tether'
    }),
    new HtmlWebpackPlugin({
      template: 'index.html'
    })
  ]
};

if (process.env.NODE_ENV === 'development') {
  const webpackHMR = new webpack.HotModuleReplacementPlugin();
  webpackConfiguration.plugins.push(webpackHMR);
  webpackConfiguration.entry.push('webpack-hot-middleware/client');
}

if (process.env.NODE_ENV === 'production') {
  const webpackNoErrors = new webpack.NoErrorsPlugin();
  const webpackUglify = new webpack.optimize.UglifyJsPlugin({
    noerr: true
  });
  webpackConfiguration.plugins.push(
    webpackUglify,
    webpackNoErrors
  );
}

module.exports = webpackConfiguration;
<|endoftext|>


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

const parts = require('./webpack.parts');

const PATHS = {
  app: path.join(__dirname, 'app'),
  reactDemo: path.join(__dirname, 'app', 'react'),
  build: path.join(__dirname, 'build'),
};

const commonConfig = merge([
  {
    output: {
      path: PATHS.build,
      filename: '[name].js',
    },
  },
  parts.lintJavaScript({ include: PATHS.app }),
  parts.lintCSS({ include: PATHS.app }),
  parts.loadFonts({
    options: {
      name: '[name].[hash:8].[ext]',
    },
  }),
  parts.loadJavaScript({ include: PATHS.app }),
]);

const productionConfig = merge([
  {
    performance: {
      hints: 'warning', // 'error' or false are valid too
      maxEntrypointSize: 100000, // in bytes
      maxAssetSize: 200000, // in bytes
    },
    output: {
      chunkFilename: '[name].[chunkhash:8].js',
      filename: '[name].[chunkhash:8].js',
    },
    plugins: [
      new webpack.HashedModuleIdsPlugin(),
    ],
    recordsPath: 'records.json',
  },
  parts.clean(PATHS.build),
  parts.minifyJavaScript({ useSourceMap: true }),
  parts.minifyCSS({
    options: {
      discardComments: {
        removeAll: true,
        // Run cssnano in safe mode to avoid
        // potentially unsafe ones.
        safe: true,
      },
    },
  }),
  parts.attachRevision(),
  parts.extractBundles([
    {
      name: 'vendor',
      minChunks: ({ resource }) => (
        resource &&
        resource.indexOf('node_modules') >= 0 &&
        resource.match(/\.js$/)
      ),
    },
    {
      name: 'manifest',
      minChunks: Infinity,
    },
  ]),
  parts.generateSourceMaps({ type: 'source-map' }),
  parts.extractCSS({
    use: ['css-loader', parts.autoprefix()],
  }),
  parts.purifyCSS({
    paths: glob.sync(path.join(PATHS.app, '**', '*')),
  }),
  parts.loadImages({
    options: {
      limit: 15000,
      name: '[name].[hash:8].[ext]',
    },
  }),
  parts.setFreeVariable(
    'process.env.NODE_ENV',
    'production'
  ),
]);

const developmentConfig = merge([
  {
    output: {
      devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]',
    },
    plugins: [
      new webpack.NamedModulesPlugin(),
    ],
  },
  parts.generateSourceMaps({ type: 'cheap-module-eval-source-map' }),
  parts.devServer({
    // Customize host/port here if needed
    host: process.env.HOST,
    port: process.env.PORT,
  }),
  parts.loadCSS(),
  parts.loadImages(),
]);

module.exports = function(env) {
  const pages = [
    parts.page({
      title: 'Webpack demo',
      entry: {
        app: PATHS.app,
      },
      chunks: ['app', 'manifest', 'vendor'],
    }),
    parts.page({
      title: 'Another demo',
      path: 'another',
      entry: {
        another: path.join(PATHS.app, 'another.js'),
      },
      chunks: ['another', 'manifest', 'vendor'],
    }),
  ];
  const config = env === 'production' ?
    productionConfig :
    developmentConfig;

  return merge([commonConfig, config].concat(pages));
};
<commit_msg>Bump asset limit<commit_after>const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const glob = require('glob');

const parts = require('./webpack.parts');

const PATHS = {
  app: path.join(__dirname, 'app'),
  reactDemo: path.join(__dirname, 'app', 'react'),
  build: path.join(__dirname, 'build'),
};

const commonConfig = merge([
  {
    output: {
      path: PATHS.build,
      filename: '[name].js',
    },
  },
  parts.lintJavaScript({ include: PATHS.app }),
  parts.lintCSS({ include: PATHS.app }),
  parts.loadFonts({
    options: {
      name: '[name].[hash:8].[ext]',
    },
  }),
  parts.loadJavaScript({ include: PATHS.app }),
]);

const productionConfig = merge([
  {
    performance: {
      hints: 'warning', // 'error' or false are valid too
      maxEntrypointSize: 100000, // in bytes
      maxAssetSize: 450000, // in bytes
    },
    output: {
      chunkFilename: '[name].[chunkhash:8].js',
      filename: '[name].[chunkhash:8].js',
    },
    plugins: [
      new webpack.HashedModuleIdsPlugin(),
    ],
    recordsPath: 'records.json',
  },
  parts.clean(PATHS.build),
  parts.minifyJavaScript({ useSourceMap: true }),
  parts.minifyCSS({
    options: {
      discardComments: {
        removeAll: true,
        // Run cssnano in safe mode to avoid
        // potentially unsafe ones.
        safe: true,
      },
    },
  }),
  parts.attachRevision(),
  parts.extractBundles([
    {
      name: 'vendor',
      minChunks: ({ resource }) => (
        resource &&
        resource.indexOf('node_modules') >= 0 &&
        resource.match(/\.js$/)
      ),
    },
    {
      name: 'manifest',
      minChunks: Infinity,
    },
  ]),
  parts.generateSourceMaps({ type: 'source-map' }),
  parts.extractCSS({
    use: ['css-loader', parts.autoprefix()],
  }),
  parts.purifyCSS({
    paths: glob.sync(path.join(PATHS.app, '**', '*')),
  }),
  parts.loadImages({
    options: {
      limit: 15000,
      name: '[name].[hash:8].[ext]',
    },
  }),
  parts.setFreeVariable(
    'process.env.NODE_ENV',
    'production'
  ),
]);

const developmentConfig = merge([
  {
    output: {
      devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]',
    },
    plugins: [
      new webpack.NamedModulesPlugin(),
    ],
  },
  parts.generateSourceMaps({ type: 'cheap-module-eval-source-map' }),
  parts.devServer({
    // Customize host/port here if needed
    host: process.env.HOST,
    port: process.env.PORT,
  }),
  parts.loadCSS(),
  parts.loadImages(),
]);

module.exports = function(env) {
  const pages = [
    parts.page({
      title: 'Webpack demo',
      entry: {
        app: PATHS.app,
      },
      chunks: ['app', 'manifest', 'vendor'],
    }),
    parts.page({
      title: 'Another demo',
      path: 'another',
      entry: {
        another: path.join(PATHS.app, 'another.js'),
      },
      chunks: ['another', 'manifest', 'vendor'],
    }),
  ];
  const config = env === 'production' ?
    productionConfig :
    developmentConfig;

  return merge([commonConfig, config].concat(pages));
};
<|endoftext|>


<commit_before>var webpack = require("webpack");
var path = require("path");

var excluded = /(node_modules|bower_components)/;

var definePlugin = new webpack.DefinePlugin({
  __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
  __PRERELEASE__: JSON.stringify(JSON.parse(process.env.BUILD_PRERELEASE || 'false'))
});

var plugins = [
  new webpack.ProvidePlugin({
      jQuery: "jquery",
      $: "jquery"
  })
];

module.exports = {
  entry: "./main",
  context: path.join(__dirname, "/troposphere/static/js"),
  output: {
    path: path.join(__dirname, "/troposphere/assets"),
    publicPath: "/assets/",
    filename: "bundle.js"
  },
  module: {
    loaders: [
      { test: /\.jsx?$/, loader: "babel", exclude: excluded }
    ]
  },
  plugins: plugins,
  resolve: {
    alias: {
      bootstrap: "bootstrap-sass",
      highcharts: "highcharts-commonjs"
    },
    root: [
      path.join(__dirname, "/troposphere/static/js")
    ],
    extensions: ["", ".js", ".scss", ".sass"]
  }
};
<commit_msg>add support for style loading<commit_after>"use strict";
var path = require("path");
var webpack = require("webpack");
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var plugins = [
    new webpack.ProvidePlugin({
      "jQuery": "jquery"
    }),
    new ExtractTextPlugin("app.css", { allChunks: true})
];

var definePlugin = new webpack.DefinePlugin({
  __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
  __PRERELEASE__: JSON.stringify(JSON.parse(process.env.BUILD_PRERELEASE || 'false'))
});

var plugins = [
  new webpack.ProvidePlugin({
      jQuery: "jquery",
      $: "jquery"
  })
];

module.exports = {
  entry: "./main",
  context: path.join(__dirname, "/troposphere/static/js"),
  output: {
    path: path.join(__dirname, "/troposphere/assets"),
    publicPath: "/assets/",
    filename: "bundle.js"
  },
  module: {
    loaders: [
      { test: /\.js$/, loader: "babel", exclude: /node_modules/ },
      { test: /\.(scss|sass)/, loader: ExtractTextPlugin.extract("style", "css!sass") }
    ]
  },
  plugins: plugins,
  resolve: {
    alias: {
      bootstrap: "bootstrap-sass",
      css: path.join(__dirname, "/troposphere/static/css/app"),
      highcharts: "highcharts-commonjs"
    },
    root: [
      path.join(__dirname, "/troposphere/static/js"),
      path.join(__dirname, "/troposphere/static/css/app")
    ],
    extensions: ["", ".js", ".scss", ".sass"]
  }
};
<|endoftext|>


<commit_before>var createConfig = require('hjs-webpack')

var config = createConfig({
  in: './app/scripts/main.js',
  out: 'dist',
  clearBeforeBuild: '!(locale|img|favicon.ico)'
})

// Handle js-ipfs-api
config.module.loaders.push({
  test: /\.js$/,
  include: /node_modules\/(hoek|qs|wreck|boom|ipfs-api)/,
  loader: 'babel-loader'
})

config.externals = {
  net: '{}',
  fs: '{}',
  tls: '{}',
  console: '{}',
  'require-dir': '{}'
}

module.exports = config
<commit_msg>config(webpack): Add correct http replacements<commit_after>var createConfig = require('hjs-webpack')

var config = createConfig({
  in: './app/scripts/main.js',
  out: 'dist',
  clearBeforeBuild: '!(locale|img|favicon.ico)'
})

// Handle js-ipfs-api
config.module.loaders.push({
  test: /\.js$/,
  include: /node_modules\/(hoek|qs|wreck|boom|ipfs-api)/,
  loader: 'babel-loader'
})

config.externals = {
  net: '{}',
  fs: '{}',
  tls: '{}',
  console: '{}',
  'require-dir': '{}'
}

config.resolve = {
  modulesDirectories: [
    'node_modules'
  ],
  alias: {
    http: 'stream-http',
    https: 'https-browserify'
  }
}

module.exports = config
<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');

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

const config = {
    entry: isProduction
        ? [
            'babel-polyfill',
            './src/main.js'
        ]
        : [
            'babel-polyfill',

            'react-hot-loader/patch', // activate HMR for React
            'webpack-hot-middleware/client?path=http://localhost:3000/__webpack_hmr', // bundle the client for webpack-hot-middleware and connect to the provided endpoint

            './src/main.js',
        ],

    resolve: {
        extensions: ['.js', '.jsx', '.json'],
    },

    output: {
        path: path.join(__dirname, 'dist/public/'),
        filename: isProduction
            ? 'assets/scripts/[name].[chunkhash].js'
            : 'main.js',
    },

    module: {
        rules: [
            {
                test: /\.css$/,
                use: isProduction
                    ? ExtractTextPlugin.extract({fallback: 'style-loader', use: ['css-loader']})
                    : ['style-loader', 'css-loader']
            },
            {
                test: /\.jsx?$/,
                use: ['babel-loader'],
                include: path.join(__dirname, 'src'),
            },
        ],
    },

    plugins: [
        new ProgressBarPlugin(),

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

        isProduction
            ? null
            : new webpack.HotModuleReplacementPlugin(), // enable HMR globally
        isProduction
            ? null
            : new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
        isProduction
            ? null
            : new webpack.NoEmitOnErrorsPlugin(), // do not emit compiled assets that include errors

        isProduction
            ? new ExtractTextPlugin({filename: "assets/styles/[name].[chunkhash].css"})
            : null,

        isProduction
            ? new webpack.optimize.CommonsChunkPlugin({
                name: 'vendor',
                minChunks: module => /node_modules/.test(module.resource)
            })
            : null,

        isProduction
            ? new webpack.optimize.CommonsChunkPlugin({name: 'manifest'})
            : null,

        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, 'src/index.html'),
            minify: isProduction ? {collapseWhitespace: true, collapseInlineTagWhitespace: true} : false,
            alwaysWriteToDisk: true,
        }),
        new HtmlWebpackHarddiskPlugin(),

        new CopyWebpackPlugin([
            {
                context: 'src/assets/media',
                from: '**/*',
                to: 'assets/media'
            }
        ])
    ].filter(Boolean),

    devtool: isProduction
        ? 'none'
        : 'cheap-module-eval-source-map',

    performance: {
        maxAssetSize: 500000
    },
};

module.exports = config;
<commit_msg>update webpack<commit_after>const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');

const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || 'localhost';
const NODE_ENV = process.env.NODE_ENV;
const isProduction = (NODE_ENV === 'production');

const config = {
    entry: isProduction
        ? [
            'babel-polyfill',
            './src/main.js'
        ]
        : [
            'babel-polyfill',

            'react-hot-loader/patch', // activate HMR for React
            `webpack-hot-middleware/client?path=http://${HOST}:${PORT}/__webpack_hmr`, // bundle the client for webpack-hot-middleware and connect to the provided endpoint

            './src/main.js',
        ],

    resolve: {
        extensions: ['.js', '.jsx', '.json'],
    },

    output: {
        path: path.join(__dirname, 'dist/public/'),
        filename: isProduction
            ? 'assets/scripts/[name].[chunkhash].js'
            : 'main.js',
    },

    module: {
        rules: [
            {
                test: /\.css$/,
                use: isProduction
                    ? ExtractTextPlugin.extract({fallback: 'style-loader', use: ['css-loader']})
                    : ['style-loader', 'css-loader']
            },
            {
                test: /\.jsx?$/,
                use: ['babel-loader'],
                include: path.join(__dirname, 'src'),
            },
        ],
    },

    plugins: [
        new ProgressBarPlugin(),

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

        isProduction
            ? null
            : new webpack.HotModuleReplacementPlugin(), // enable HMR globally
        isProduction
            ? null
            : new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
        isProduction
            ? null
            : new webpack.NoEmitOnErrorsPlugin(), // do not emit compiled assets that include errors

        isProduction
            ? new ExtractTextPlugin({filename: "assets/styles/[name].[chunkhash].css"})
            : null,

        isProduction
            ? new webpack.optimize.CommonsChunkPlugin({
                name: 'vendor',
                minChunks: module => /node_modules/.test(module.resource)
            })
            : null,

        isProduction
            ? new webpack.optimize.CommonsChunkPlugin({name: 'manifest'})
            : null,

        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, 'src/index.html'),
            minify: isProduction ? {collapseWhitespace: true, collapseInlineTagWhitespace: true} : false,
            alwaysWriteToDisk: true,
        }),
        new HtmlWebpackHarddiskPlugin(),

        new CopyWebpackPlugin([
            {
                context: 'src/assets/media',
                from: '**/*',
                to: 'assets/media'
            }
        ])
    ].filter(Boolean),

    devtool: isProduction
        ? 'none'
        : 'cheap-module-eval-source-map',

    performance: {
        maxAssetSize: 500000
    },
};

module.exports = config;
<|endoftext|>


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

module.exports = {
  devtool: 'cheap-module-eval-source-map',
  debug: true,
  entry: {
    main: './src/main.ts',
    vendor: [
      'angular2/bundles/angular2-polyfills',
      'angular2/platform/browser',
      'angular2/core',
      'angular2/common',
      'angular2/router',
      'angular2/http'
    ]
  },
  output: {
    path: './dist',
    filename: '[name].bundle.js',
    sourceMapFilename: '[name].map',
    chunkFilename: '[id].chunk.js'
  },
  resolve: {
    root: [ path.join(__dirname, 'src') ],
    extensions: ['', '.ts', '.tsx', '.js']
  },
  module: {
    loaders: [
      { test: /\.tsx?$/, loader: 'ts-loader', exclude: [/\.(spec|e2e)\.tsx?$/] },
      { test: /\.html$/, loader: 'raw-loader' },
      { test: /\.less$/, loader: 'raw-loader!postcss-loader!less-loader' }
    ],
    noParse: [ path.join(__dirname, 'node_modules', 'angular2', 'bundles') ]
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(true),
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor', minChunks: Infinity}),
    new webpack.DefinePlugin({
      MODE: JSON.stringify('dev')
    })
  ],
  devServer: {
    host: 'localhost',
    port: 9000,
    contentBase: 'src/',
    historyApiFallback: true
  },
  // thirdparty loader-configs
  postcss: function () {
    return [ autoprefixer ];
  }
};
<commit_msg>update<commit_after>var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');

module.exports = {
  devtool: 'source-map',
  debug: true,
  entry: {
    main: './src/main.ts',
    vendor: [
      'es6-shim',
      'angular2/bundles/angular2-polyfills',
      'angular2/platform/browser',
      'angular2/core',
      'angular2/common',
      'angular2/router',
      'angular2/http',
      'rxjs/Rx'
    ]
  },
  output: {
    path: './dist',
    filename: '[name].bundle.js',
    sourceMapFilename: '[name].map',
    chunkFilename: '[id].chunk.js'
  },
  resolve: {
    root: [ path.join(__dirname, 'src') ],
    extensions: ['', '.ts', '.js']
  },
  module: {
    loaders: [
      { test: /\.ts$/, loader: 'ts-loader', exclude: [/\.(spec|e2e)\.ts$/] },
      { test: /\.html$/, loader: 'raw-loader' },
      { test: /\.less$/, loader: 'raw-loader!postcss-loader!less-loader' }
    ],
    noParse: [ path.join(__dirname, 'node_modules', 'angular2', 'bundles') ]
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(true),
    new webpack.optimize.CommonsChunkPlugin({name: 'vendor', minChunks: Infinity}),
    new webpack.DefinePlugin({
      MODE: JSON.stringify('dev')
    })
  ],
  devServer: {
    host: 'localhost',
    port: 9000,
    contentBase: 'src/',
    historyApiFallback: true
  },
  // thirdparty loader-configs
  postcss: function () {
    return [ autoprefixer ];
  }
};
<|endoftext|>