const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const webpack = require('webpack');
const pug = require('./webpack_config/pug');
const devserver = require('./webpack_config/devserver');
const sass = require('./webpack_config/sass');
//const compass = require('./webpack_config/compass');
//const resourcesLoader = require('./webpack_config/resources.loader');
const css = require('./webpack_config/css');
const extractCSS = require('./webpack_config/css.extract');
const uglifyJS = require('./webpack_config/uglifyjs');
//babel
const babel = require('./webpack_config/babel');
//const babelLoader = require('./webpack_config/babelLoader');
const typescript = require('./webpack_config/typescript');
//file-loader
const images = require('./webpack_config/images');
const fonts = require('./webpack_config/fonts');
const PATHS = {
source: path.join(__dirname, '_autovep'),
build: path.join(__dirname, '_autovep-build'),
};
const common = merge([
{
entry: {
'index': PATHS.source + '/pages/index/index.js',
/* end */
},
output: {
path: PATHS.build,
filename: './assets/js/[name].js',
library: '[name]',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true,
},
plugins: [
new HtmlWebpackPlugin({
favicon: '_autovep/favicon.png',
filename: 'index.html',
chunks: ['index', 'common'],
template: PATHS.source + '/pages/index/index.pug',
}),
/* end */
new webpack.optimize.CommonsChunkPlugin({
name: 'common'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
],
},
pug(),
images(),
fonts(),
]);
module.exports = function(env) {
process.env.mode = env;
if (env === 'production') {
return merge([
common,
extractCSS(),
uglifyJS,
babel,
]);
} else if (env === 'development') {
return merge([
common,
devserver(),
sass(),
//compass(),
//resourcesLoader(),
css(),
babel,
]);
}
};