Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
120 lines (106 loc) · 3.54 KB
/
Copy pathwebpack.config.js
File metadata and controls
120 lines (106 loc) · 3.54 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
116
117
118
119
120
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const path = require('path');
const PORT = 8003;
const devMode = process.env.NODE_ENV !== 'production';
const TARGET_NAME = 'css';
const TARGET = path.join(__dirname, TARGET_NAME);
const PUBLIC_PATH = devMode ? `http://localhost:${PORT}/${TARGET_NAME}/` : `./${TARGET_NAME}/`;
const ASSETS_PUBLIC_PATH = devMode ? `http://localhost:${PORT}/${TARGET_NAME}/` : './';
const BOOTSWATCH_THEMES = [
'cerulean',
'cosmo',
'cyborg',
'darkly',
'flatly',
'journal',
'litera',
'lumen',
'lux',
'materia',
'minty',
'pulse',
'sandstone',
'simplex',
'sketchy',
'slate',
'solar',
'spacelab',
'superhero',
'united',
'yeti'
];
const bootswatchEntries = BOOTSWATCH_THEMES.reduce((acc, name) => {
acc[`bootswatch-${name}`] = `./scss/bootswatch/_${name}.scss`;
return acc;
}, {});
const MATERIAL_THEMES = ['amber', 'blue', 'brown', 'darkroom', 'deep-orange', 'deep-purple', 'indigo', 'light-green', 'lime', 'purple', 'red', 'teal'];
const materialEntries = MATERIAL_THEMES.reduce((acc, name) => {
acc[`material-${name}`] = `./scss/material/_${name}.scss`;
return acc;
}, {});
module.exports = {
devtool: 'source-map',
entry: {
theme: './scss/theme.scss',
photoswipe: './scss/photoswipe.scss',
slick: './scss/slick.scss',
typeface: './scss/typeface.scss',
'bootstrap-social': './scss/bootstrap-social.scss',
'selectize-bootstrap': './scss/selectize-bootstrap.scss',
'bootstrap-default': './scss/bootstrap-default.scss',
'bootstrap-darkroom': './scss/bootstrap-darkroom.scss',
...bootswatchEntries,
...materialEntries
},
output: {
path: TARGET,
publicPath: PUBLIC_PATH
},
module: {
rules: [
{
test: /\.scss$/,
use: [
// fallback to style-loader in development
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /\.(png|jpg|jpeg|gif|ico)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'images/[name].[ext]', // @TODO: find a way to inject [hash] in templates
publicPath: ASSETS_PUBLIC_PATH
}
}
]
},
{
test: /\.(svg|ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]', // @TODO: find a way to inject [hash:8] in templates
publicPath: ASSETS_PUBLIC_PATH
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? '[name].css' : '[name].css', // @TODO: find a way to inject [hash] in templates
chunkFilename: devMode ? '[id].css' : '[id].css' // @TODO: find a way to inject [hash] in templates
}),
new CleanWebpackPlugin(`./${TARGET_NAME}`)
]
};