-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
58 lines (47 loc) · 1.39 KB
/
vue.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
const fs = require('fs');
const path = require('path');
//
const chalk = require('chalk');
const svgstore = require('svgstore');
//
const config = require('./config');
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/proportions/'
: '/',
pages: {
index: {
// entry for the page
entry: 'src/main.js',
title: 'Proportions, but nicer.',
},
},
chainWebpack: webpackConfig => {
// Build a SVG Sprite during build
if (fs.existsSync(config.svgstore.src)) {
console.log(chalk.green('\nCreating a SVG Sprite'));
let sprite = svgstore();
let icons = 0;
fs.readdir(config.svgstore.src, (err, files) => {
if (err) throw err;
files.forEach(file => {
let filePath = `${config.svgstore.src}/${file}`;
let isFile = fs.statSync(filePath).isFile();
let isSvg = path.extname(file) == '.svg';
if (isFile && isSvg) {
icons ++;
sprite.add(path.basename(file, '.svg'), fs.readFileSync(filePath, 'utf8'))
}
});
// If there's some icons, create the file
if (icons) {
console.log(chalk.green(`\nFound ${icons} ${icons > 1 ? 'icons' : 'icon'}. Creating Sprite...`));
fs.writeFile(config.svgstore.dest, sprite, () =>
console.log(chalk.green.bold(`\n✓ Sprite successfully created `)));
} else {
console.log(chalk.yellow(`\nFound ${icons} icons. Skipping Sprite...`));
}
});
}
},
};