phpmyadmin/webpack.config.babel.js
Piyush Vijay 8c986d8308 Weekly progress.
1). Microhistory added in classes for modular code
2). Code is structured and camel casing of varables is done for removing linter warnings.
3). JQuery plugins are added in some files.
4). jQplot is working for server_status_queries and server_status_monitor.
5). Work started for Dabatase, SQl and Table files.
Some changes are stll left for server_status_monitor and sql.js
Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
2018-08-10 13:36:58 +05:30

100 lines
2.5 KiB
JavaScript

import path from 'path';
import webpack from 'webpack';
import BundleAnalyzerPlugin from 'webpack-bundle-analyzer';
function WebpackConfig (env) {
let BundleAnalyzer = BundleAnalyzerPlugin.BundleAnalyzerPlugin;
// environment either development or production
var MODE;
if (typeof env !== 'undefined'
&& env.production === true
) {
MODE = 'production';
} else {
MODE = 'development';
}
var WEBPACK_HOST = 'http://localhost';
// port number of dev server
// let dev server port be 3307
var WEBPACK_PORT = 3307;
var PUBLIC_PATH;
if (MODE === 'development') {
PUBLIC_PATH = WEBPACK_HOST + ':' + WEBPACK_PORT + '/js/dist/';
} else {
PUBLIC_PATH = 'js/dist/';
}
var module = {
rules: [
{ test: /\.(js)$/, use: 'babel-loader', exclude: /node_modules/ }
]
};
var devServer = {
port: WEBPACK_PORT,
hot: false,
headers: {
'Access-Control-Allow-Origin': '*'
},
};
var plugins = [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ProvidePlugin({
jQuery: 'jquery'
}),
];
if (MODE === 'development') {
plugins.push(new BundleAnalyzer());
}
return {
mode: MODE,
entry: {
index_new: './js/src/index.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'js/dist'),
publicPath: PUBLIC_PATH
},
optimization: {
splitChunks: {
chunks: 'all',
minSize: 30000,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
module: module,
resolve: {
extensions: ['.js']
},
devServer: devServer,
plugins: plugins
};
};
export default WebpackConfig;