-
Notifications
You must be signed in to change notification settings - Fork 588
/
css.webpack.js
57 lines (54 loc) · 1.6 KB
/
css.webpack.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
const config = require('./config');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackRTLPlugin = require('webpack-rtl-plugin');
const cssSource = `./${config.sourcePath}/${config.cssDirectory}`;
const entry = {
main: [`${cssSource}/main.styl`],
styleguide: [`${cssSource}/styleguide.styl`],
surveys: [`${cssSource}/surveys.styl`],
training: [`${cssSource}/training.styl`],
};
module.exports = (env) => {
const mode = env.development ? 'development' : 'production';
return {
mode,
entry,
module: {
rules: [
{
test: /\.styl$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
// Compiles Stylus to CSS
loader: 'stylus-native-loader',
options: {
includeCSS: true,
vendors: true
}
}
]
},
{
// this inlines resources if they are less than 8KB
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
type: 'asset'
}
]
},
plugins: [
// extracts CSS to a separate file
new MiniCssExtractPlugin({
filename: env.development ? '../stylesheets/[name].css' : '../stylesheets/[name].[contenthash].css',
}),
// generates a RTL version of the emitted CSS files
// this is done only in production/coverage
...(env.production || env.coverage ? [new WebpackRTLPlugin({
filename: '../stylesheets/rtl-[name].[contenthash].css'
})] : []),
],
watch: env.watch_js,
stats: 'minimal',
};
};