forked from kodeklubben/codeclub-viewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildconstants.js
39 lines (34 loc) · 1.45 KB
/
buildconstants.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
/* eslint-env node */
const path = require('path');
const fs = require('fs');
// Use 'subDir' to serve the site from a subdir, e.g. subDir='beta' for http://kodeklubben.github.io/beta
// The value of subDir is read from the file 'url-path-prefix.config' in the root folder, if it exists.
const subDirFile = './url-path-prefix.config';
let subDir = fs.existsSync(subDirFile) ? fs.readFileSync(subDirFile, 'utf8').trim() : '';
if (subDir.startsWith('/')) { subDir = subDir.slice(1); }
if (subDir.endsWith('/')) { subDir = subDir.slice(0, -1); }
const buildBaseDir = path.join(__dirname, 'dist');
const buildDir = path.join(buildBaseDir, subDir);
const isHot = process.argv.indexOf('--hot') >= 0;
// Webpack needs final slash in publicPath to rewrite relative paths correctly
const publicPathWithoutSlash = '/' + subDir;
const publicPath = '/' + subDir + (subDir ? '/' : '');
const lessonRepo = path.resolve(__dirname, '../oppgaver');
const lessonSrc = path.resolve(lessonRepo, 'src');
const lessonFiltertags = path.resolve(__dirname, '../oppgaver/filtertags');
const assets = path.resolve(__dirname, './src/assets');
const bootstrapStyles = path.resolve(__dirname, './node_modules/bootstrap-sass/assets/stylesheets/bootstrap');
const filenameBase = isHot ? '[name]' : '[name].[chunkhash:6]';
module.exports = {
buildBaseDir,
buildDir,
isHot,
publicPathWithoutSlash,
publicPath,
lessonRepo,
lessonSrc,
lessonFiltertags,
assets,
bootstrapStyles,
filenameBase,
};