1 | const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
2 | const path = require('path');
|
3 | const webpack = require('webpack');
|
4 | const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
5 |
|
6 | module.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 | }
|
27 | },
|
28 | plugins: [
|
29 | new webpack.optimize.ModuleConcatenationPlugin(),
|
30 | new webpack.optimize.CommonsChunkPlugin({
|
31 | minChunks: ({ resource }) => /node_modules/.test(resource),
|
32 | name: "vendor"
|
33 | }),
|
34 | new webpack.DefinePlugin({
|
35 | 'process.env': {
|
36 | 'NODE_ENV': JSON.stringify('production')
|
37 | }
|
38 | }),
|
39 | new webpack.IgnorePlugin(/require-all/),
|
40 | new ProgressBarPlugin(),
|
41 | new ExtractTextPlugin({
|
42 | allChunks: true,
|
43 | filename: '[name].css'
|
44 | }),
|
45 | new webpack.optimize.UglifyJsPlugin({
|
46 | sourceMap: false,
|
47 | mangle: true,
|
48 | compress: {
|
49 | warnings: false,
|
50 | pure_getters: true,
|
51 | unsafe: true,
|
52 | unsafe_comps: true,
|
53 | screw_ie8: true
|
54 | },
|
55 | output: {
|
56 | comments: false,
|
57 | }
|
58 | })
|
59 | ],
|
60 | module: {
|
61 | rules: [
|
62 | {
|
63 | test: /\.jsx?$/,
|
64 | include: [
|
65 | path.resolve(projectPath, 'src'),
|
66 | path.resolve(projectPath, 'node_modules/preact-compat')
|
67 | ],
|
68 | use: {
|
69 | loader: 'babel-loader',
|
70 | }
|
71 | },
|
72 |
|
73 | {
|
74 | test: /\.css$/,
|
75 | use: ExtractTextPlugin.extract({
|
76 | fallback: 'style-loader',
|
77 | use: [
|
78 | {
|
79 | loader: "css-loader",
|
80 | options: {
|
81 | modules: true,
|
82 | sourceMap: true,
|
83 | importLoaders: 1,
|
84 | localIdentName: "[name]--[local]--[hash:base64:5]"
|
85 | }
|
86 | },
|
87 | {
|
88 | loader: 'postcss-loader',
|
89 | options: {
|
90 | path: __dirname+'/postcss.config.js'
|
91 | }
|
92 | }
|
93 | ]
|
94 | })
|
95 | }
|
96 | ]
|
97 | }
|
98 | }
|
99 |
|
100 |
|
101 |
|
102 | }
|
103 |
|