-
Notifications
You must be signed in to change notification settings - Fork 2
/
Brocfile.js
executable file
·82 lines (69 loc) · 2.25 KB
/
Brocfile.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use strict";
/* eslint-env node */
require("dotenv").config();
const Merge = require("broccoli-merge-trees");
const Sass = require("broccoli-sass-source-maps");
const LiveReload = require("broccoli-inject-livereload");
const Autoprefixer = require("broccoli-autoprefixer");
const CssOptimizer = require("broccoli-csso");
const Rollup = require("broccoli-rollup");
const Babel = require("broccoli-babel-transpiler");
const mv = require("broccoli-stew").mv;
const rm = require("broccoli-stew").rm;
const nodeResolve = require("rollup-plugin-node-resolve");
const replace = require("rollup-plugin-replace");
const builtins = require("rollup-plugin-node-builtins");
const globals = require("rollup-plugin-node-globals");
const commonjs = require("rollup-plugin-commonjs");
// const vue = require('rollup-plugin-vue');
const plugins = [
replace({
"process.env.NODE_ENV": JSON.stringify(process.env.EMBER_ENV),
}),
nodeResolve({ jsnext: true, main: true }),
commonjs({ include: "node_modules/**" }),
builtins(),
globals(),
// vue(),
];
let pubFiles = new LiveReload("public");
if (process.env.EMBER_ENV === "production") {
pubFiles = "public";
}
const stylePaths = [
"app/styles",
"node_modules/font-awesome/scss",
"node_modules/normalize-css",
"node_modules/yoga-sass/assets",
// Add any extra libs you want to import from node modules in sass here...
// 'node_modules/bulma',
];
const appNoSass = rm("app", "**/*.scss");
const babelScript = new Babel(appNoSass);
const appScript = new Rollup(babelScript, {
rollup: {
sourceMap: true,
entry: "./index.js",
plugins,
targets: [{ dest: "app.js", format: "iife" }],
},
});
const compiledSass = new Sass(stylePaths, "app.scss", "app.css", {});
const optimizedCSS = new CssOptimizer(compiledSass);
const styles = new Autoprefixer(optimizedCSS);
if (process.env.EMBER_ENV === "test") {
const testTree = new Merge([
mv(babelScript, "app"),
mv(new Babel("tests"), "tests"),
]);
const testJs = new Rollup(testTree, {
rollup: {
entry: "./tests/index-test.js",
plugins,
targets: [{ dest: "tests.js", format: "iife" }],
},
});
module.exports = new Merge([pubFiles, styles, appScript, testJs]);
} else {
module.exports = new Merge([pubFiles, styles, appScript]);
}