-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
60 lines (55 loc) · 1.46 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
59
60
var glob = require('glob');
var path = require('path');
var fs = require('fs');
var pagesPath = path.resolve(__dirname, './src/pages');
var root = path.dirname(__dirname);
console.log(path.join(root, 'templates'));
var searchPages = function (){
var pages = {};
var entryFiles = glob.sync(pagesPath + '/*/entry.js');
entryFiles.forEach((filePath) => {
var filename = filePath.substring(filePath.lastIndexOf('\/') + 1, filePath.length);
var basename = path.basename(path.dirname(filePath));
var htmlName = basename + '.html';
pages[basename] = {
entry: filePath,
template: filePath.replace(filename, htmlName),
filename: htmlName
};
});
console.log(pages);
return pages;
};
var pages = {};
var isProd = function (){
return process.env.NODE_ENV === 'production';
};
var getBasePath = function (){
return isProd() ? '' : '/spa/';
};
var getAssetsDir = function (){
return './static/';
};
var devServer =
{
public: 'localhost:8080',
host: '0.0.0.0',
port: 8080,
compress: true,
publicPath: '/spa/',
disableHostCheck: true,
// https: {
// key: fs.readFileSync('..../privkey.pem'),
// cert: fs.readFileSync('..../fullchain.pem')
// },
};
const config = {
pages: Object.assign({}, pages, searchPages()),
baseUrl: getBasePath(),
assetsDir: getAssetsDir(),
outputDir: path.join('templates', 'spa'),
configureWebpack: {},
devServer: devServer,
css: {}
};
module.exports = config;