forked from saddlebackdev/react-cm-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
115 lines (113 loc) · 3.76 KB
/
Copy pathwebpack.config.js
File metadata and controls
115 lines (113 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = (env, options) => {
const isDevMode = options.mode === 'development';
return {
entry: {
bundle: './docs/src/index.js',
commons: [ 'react-syntax-highlighter' ],
},
devServer: {
historyApiFallback: true,
inline: true,
port: 8082,
},
output: {
path: path.join(__dirname, './docs/build'),
filename: 'js/[name].[hash].js',
chunkFilename: 'js/[name].[chunkhash].js',
publicPath: '/',
},
devtool: 'eval',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader',
}, {
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [
require('autoprefixer')(),
],
sourceMap: isDevMode,
},
},
'resolve-url-loader',
'sass-loader?outputStyle=expanded&includePaths[]=' + path.resolve(__dirname, 'docs/src/scss') + '&includePaths[]=' + path.resolve(__dirname, 'src/scss'),
],
}, {
test: /\.(ico|png|jpg|gif|svg|eot|ttf|woff|woff(2)?)(\?[a-z0-9=\.]+)?$/,
loader: 'file-loader?name=[path][name].[ext]?[hash]&context=./src',
}, {
test: /\.(sketch|pdf?)(\?[a-z0-9=\.]+)?$/,
loader: 'file-loader?name=files/[name].[ext]?[hash]&context=./src',
},
],
},
resolve: {
extensions: [
'.js',
'.jsx',
'.scss',
'.ico',
'.png',
'.jpg',
'.gif',
'.eot',
'.ttf',
'.woff',
'.woff2',
'.svg',
'.json',
'.sketch',
'.pdf',
],
modules: [
'node_modules',
'docs/src',
'docs/src/js',
'docs/src/scss',
'src',
],
alias: {
'react-cm-ui': path.resolve(__dirname, 'src'),
'css-cm-ui': path.resolve(__dirname, 'src/style.scss'),
},
},
optimization: {
splitChunks: {
minChunks: Infinity,
name: 'commons',
},
},
plugins: [
new webpack.LoaderOptionsPlugin({
proxy: {
'*': 'http://0.0.0.0:5000',
},
}),
new HtmlWebpackPlugin({
filename: 'index.html',
title: 'Church Management UI Docs',
template: 'docs/template.ejs',
}),
new MiniCssExtractPlugin({
filename: 'css/bundle.css',
allChunks: true,
}),
new webpack.DefinePlugin({
__UI_DOCS_VERSION__: (typeof process.env.CM_UI_DOCS_VERSION === 'undefined') ?
'"?"' : '"' + process.env.CM_UI_DOCS_VERSION + '"',
}),
],
};
};