yahoi
Version:
Yet Another Highly Opinionated Isomorphic Framework
104 lines (95 loc) • 2.55 kB
JavaScript
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = function(props) {
let projectPath = props.projectPath;
return {
entry: ['babel-polyfill', './src/Client/index.js'],
stats: {
verbose: true
},
output: {
filename: '[name].js',
chunkFilename: '[name].js',
path: path.resolve(projectPath, 'dist', 'public', 'clientjs'),
publicPath: "/public/clientjs/"
},
resolve: {
alias: {
Components: './src/Components',
Containers: './src/Containers',
Actions: './src/Actions'
}
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.CommonsChunkPlugin({
minChunks: ({ resource }) => /node_modules/.test(resource),
name: "vendor"
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.IgnorePlugin(/require-all/),
new ProgressBarPlugin(),
new ExtractTextPlugin({
allChunks: true,
filename: '[name].css'
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: true,
compress: {
warnings: false,
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true
},
output: {
comments: false,
}
})
],
module: {
rules: [
{
test: /\.jsx?$/,
include: [
path.resolve(projectPath, 'src'),
path.resolve(projectPath, 'node_modules/preact-compat')
],
use: {
loader: 'babel-loader',
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: "css-loader",
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
localIdentName: "[name]--[local]--[hash:base64:5]"
}
},
{
loader: 'postcss-loader',
options: {
path: __dirname+'/postcss.config.js'
}
}
]
})
}
]
}
}
}