UNPKG

2.6 kBJavaScriptView Raw
1const ProgressBarPlugin = require('progress-bar-webpack-plugin');
2const path = require('path');
3const webpack = require('webpack');
4const ExtractTextPlugin = require("extract-text-webpack-plugin");
5
6module.exports = function(props) {
7
8 let projectPath = props.projectPath;
9
10 return {
11 entry: ['babel-polyfill', './src/Client/index.js'],
12 stats: {
13 verbose: true
14 },
15 output: {
16 filename: '[name].js',
17 chunkFilename: '[name].js',
18 path: path.resolve(projectPath, 'dist', 'public', 'clientjs'),
19 publicPath: "/public/clientjs/"
20 },
21 resolve: {
22 alias: {
23 Components: './src/Components',
24 Containers: './src/Containers',
25 Actions: './src/Actions',
26 Environment: './src/Environments/production'
27 }
28 },
29 plugins: [
30 new webpack.optimize.ModuleConcatenationPlugin(),
31 new webpack.optimize.CommonsChunkPlugin({
32 minChunks: ({ resource }) => /node_modules/.test(resource),
33 name: "vendor"
34 }),
35 new webpack.DefinePlugin({
36 'process.env': {
37 'NODE_ENV': JSON.stringify('production')
38 }
39 }),
40 new webpack.IgnorePlugin(/require-all/),
41 new ProgressBarPlugin(),
42 new ExtractTextPlugin({
43 allChunks: true,
44 filename: '[name].css'
45 }),
46 new webpack.optimize.UglifyJsPlugin({
47 sourceMap: false,
48 mangle: true,
49 compress: {
50 warnings: false,
51 pure_getters: true,
52 unsafe: true,
53 unsafe_comps: true,
54 screw_ie8: true
55 },
56 output: {
57 comments: false,
58 }
59 })
60 ],
61 module: {
62 rules: [
63 {
64 test: /\.jsx?$/,
65 include: [
66 path.resolve(projectPath, 'src'),
67 path.resolve(projectPath, 'node_modules/preact-compat')
68 ],
69 use: {
70 loader: 'babel-loader',
71 }
72 },
73
74 {
75 test: /\.css$/,
76 use: ExtractTextPlugin.extract({
77 fallback: 'style-loader',
78 use: [
79 {
80 loader: "css-loader",
81 options: {
82 modules: true,
83 sourceMap: true,
84 importLoaders: 1,
85 localIdentName: "[name]--[local]--[hash:base64:5]"
86 }
87 },
88 {
89 loader: 'postcss-loader',
90 options: {
91 path: __dirname+'/postcss.config.js'
92 }
93 }
94 ]
95 })
96 }
97 ]
98 }
99 }
100
101
102
103}
104