-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrunch-config.js
67 lines (63 loc) · 1.72 KB
/
brunch-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
61
62
63
64
65
66
67
const glob = require('glob');
const assetFunctions = require('node-sass-asset-functions');
const jsEntryRoot = 'app/javascript/packs/';
const jsEntryFiles = glob.sync(`${jsEntryRoot}**/*.js`);
const jsEntryPoints = jsEntryFiles.reduce(
(result, file) => ({ ...result, [file]: file.replace(jsEntryRoot, '') }),
{}
);
const autoRequires = jsEntryFiles.reduce(
(result, file) => ({ ...result, [file.replace(jsEntryRoot, '')]: [file] }),
{}
);
const stylesEntryRoot = 'app/assets/stylesheets/packs/';
const stylesheets = glob.sync(`${stylesEntryRoot}**/*.scss`).reduce(
(result, file) => (
{
...result,
[file.replace(stylesEntryRoot, '').replace('.scss', '.css')]: file
}
),
{}
);
const imagesRoot = 'app/assets/images/';
const imageSourceFiles = glob.sync(`${imagesRoot}**/*`);
const imageOutputFiles =
imageSourceFiles.map(file => `/packs/${file.replace(imagesRoot, '')}`);
module.exports = {
conventions: {
assets: /assets\/images\//,
ignored: [/\/_/, /stylesheets\/(?!packs)/]
},
files: {
javascripts: { entryPoints: jsEntryPoints },
stylesheets: { joinTo: stylesheets }
},
modules: {
autoRequire: autoRequires,
nameCleaner: path => path
},
paths: {
public: 'public/packs',
watched: ['app/javascript', 'app/assets']
},
plugins: {
fingerprint: {
alwaysRun: true,
assetsToFingerprint: imageOutputFiles,
autoReplaceAndHash: true,
destBasePath: 'public/packs/',
hashLength: 10,
manifest: './public/packs/manifest.json',
srcBasePath: 'public/packs/'
},
sass: {
functions: assetFunctions({
http_images_path: '/packs',
}),
options: {
includePaths: ['node_modules'],
}
}
}
};