-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.js
122 lines (122 loc) · 2.67 KB
/
rules.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
module.exports = {
/**
* Babel loader
* https://github.com/babel/babel-loader
*/
JS_RULE: {
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
/**
* Presets must be in this order. The 'stage-0' preset allows us
* to use arrow functions inside the body of a class component.
*/
options: {
presets: ['react', 'env', 'stage-0'],
},
},
},
/**
* Html loader
* https://webpack.js.org/loaders/html-loader/
*/
HTML_RULE: {
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: {
minimize: true,
removeComments: true,
collapseWhitespace: true,
},
},
],
},
/**
* Css loader - Exclude node_modules
* https://webpack.js.org/loaders/css-loader/
* - The postcss loader has a separate config file in project root.
* - Webpack is reading the order of the plugins from right to left
* so in this setup "postcss-loader" will be loaded first.
*/
CSS_RULE: {
test: /\.css$/,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
/** Should be set to false for postcss to work */
modules: false,
sourceMap: true,
minimize: true,
importLoaders: 1,
},
},
/**
* Postcss loader
* https://github.com/postcss/postcss-loader
*/
{
loader: 'postcss-loader',
options: {
config: { path: './postcss.config.js' },
},
},
],
},
/**
* Sass loader - Include node_modules
* https://webpack.js.org/loaders/sass-loader/
*/
SASS_RULE: {
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
includePaths: ['../src/start/css/**/*.scss'],
include: /node_modules/,
},
},
],
},
/**
* File loader - Images
* https://webpack.js.org/loaders/file-loader/
*/
FILE_RULE: {
test: /\.(jpe?g|png|gif|svg|ico)$/i,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
limit: 80000,
// name: '[name]-[hash:8].[ext]',
name: '[name].[ext]',
outputPath: './img/',
publicPath: './img/',
},
},
],
},
// File loader - Fonts
FONT_RULE: {
test: /\.(woff|woff2|eot|ttf|otf)$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
name: 'fonts/[name]-[hash].[ext]',
},
},
],
},
};