Skip to content

Instantly share code, notes, and snippets.

@petvas
Last active February 20, 2018 16:23
Show Gist options
  • Save petvas/0f65819da7685f26c0b947538b046757 to your computer and use it in GitHub Desktop.
Save petvas/0f65819da7685f26c0b947538b046757 to your computer and use it in GitHub Desktop.
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const ManifestPlugin = require('webpack-manifest-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
plugins = [
new webpack.EnvironmentPlugin(['NODE_ENV']),
new ManifestPlugin(),
new CleanWebpackPlugin([__dirname + '/src/Website/Scripts/dist']),
];
if (process.env.NODE_ENV === "production") {
plugins.push(new webpack.optimize.ModuleConcatenationPlugin({ optimizationBailout: true }));
} else {
Array.prototype.push.apply(plugins, [
new BundleAnalyzerPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NamedChunksPlugin()
]);
}
module.exports = {
context: __dirname + "/src/Website/Scripts/",
entry: "./src/app.js",
output: { path: __dirname + "/src/Website/Scripts/dist", filename: "[name].[chunkhash].js", publicPath: '/Scripts/dist/' },
plugins: plugins,
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
include: [
path.resolve(__dirname, './src')
],
options: {
configFile: path.resolve(__dirname, './.eslintrc'),
failOnError: true,
//failOnWarning: true,
},
loader: 'eslint-loader',
},
{
test: /\.js$/,
exclude: /node_modules/,
include: [
path.resolve(__dirname, './src')
],
loader: "babel-loader", // or just "babel"
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment