-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.site-branding.config.js
97 lines (91 loc) · 2.17 KB
/
webpack.site-branding.config.js
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
/**
* Webpack site-branding config
*/
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
/**
* Initialize company subdomain list for processing branding css files
*/
const subdomains = [
'company123',
'companyabc',
'companyxyz'
];
const entryConfig = {};
subdomains.forEach((subdomain) => {
entryConfig[subdomain] = `./client-branding/${subdomain}/site-branding.scss`;
});
/**
* Setup css options, if prod minimize, discard comments
*/
const cssLoaderOptions = {
sourceMap: true,
minimize: false,
discardComments: {
removeAll: false
}
};
if (process.env.arg === 'prod') {
cssLoaderOptions.minimize = true;
cssLoaderOptions.discardComments.removeAll = true;
}
module.exports = {
context: path.resolve('./src'),
entry: entryConfig,
output: {
path: path.resolve('./dist/'),
filename: 'client-branding/js/[name].ignore.js',
publicPath: '/'
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: cssLoaderOptions,
},
{
loader: 'postcss-loader',
options: {
plugins: () => [require('autoprefixer')]
}
},
{
// options: { sourceMap: true },
loader: 'sass-loader'
}
]
})
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: ['css-loader']
})
}
]
},
plugins: [
new CleanWebpackPlugin(['dist/client-branding'],
{
verbose: true
// exclude: ['img/**/*'] // <- exclude does not work
}
),
new CopyWebpackPlugin([
{ from: './client-branding/**/*', to: './', ignore: '*.scss' }
]),
new ExtractTextPlugin({
filename: 'client-branding/[name]/css/site-branding.css',
allChunks: true
})
]
};