-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
51 lines (45 loc) · 1.2 KB
/
webpack.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
const glob = require('glob');
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
// get file paths from authored css files
const filePaths = glob.sync('./src/*.css');
// get the filename from each path
const fileNames = filePaths.map(f => f.split('./src/').pop());
// build up an object setting keys to the filename, and values the file path
const files = Object.assign(
...fileNames.map((key, index) => ({ [key]: filePaths[index] }))
);
module.exports = {
entry: files,
output: {
filename: '[name]',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextWebpackPlugin.extract({
use: [
{
loader: 'css-loader',
options: { importLoaders: 1, url: false },
},
{
loader: 'postcss-loader',
},
],
}),
},
],
},
stats: {
children: false,
},
plugins: [
new CleanWebpackPlugin(['dist']),
new ExtractTextWebpackPlugin({ filename: '[name]' }),
],
};