Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 03ff2173 authored by Pierre Jarriges's avatar Pierre Jarriges
Browse files

bundle minified prod

parent 4f3e0dbf
No related branches found
No related tags found
No related merge requests found
Showing
with 1977 additions and 4615 deletions
......@@ -4,19 +4,38 @@
const fs = require("fs");
const browserify = require("browserify");
const Uglify = require("uglify-js");
const _dir = process.cwd();
const config = require("./config");
const curDir = process.cwd();
const build_conf = config.build;
const build_minified = process.argv.includes("prod");
function build_bundle(input_path, output_path) {
if (build_minified) {
const bundle = browserify()
.add(input_path)
.bundle();
let stream = "";
bundle.on("data", chunk => stream += chunk);
bundle.on("end", () => {
const minified = Uglify.minify(stream);
const out = fs.createWriteStream(output_path);
out.write(minified.code);
});
} else {
browserify()
.add(input_path)
.bundle()
.pipe(fs.createWriteStream(output_path));
}
}
// Handle home page
const b = browserify();
b.add(`${curDir}/src/main.js`)
.bundle()
.pipe(fs.createWriteStream(`${curDir}/public/main.js`));
build_bundle(`${_dir}/src/main.js`, `${_dir}/public/main.js`)
// Handle subpages
function getPageHtml(pageName, pageMeta) {
let html = fs.readFileSync(`${curDir}/public/index.html`, "utf-8");
let html = fs.readFileSync(`${_dir}/public/index.html`, "utf-8");
const setMeta = function (metaName, value) {
html = html.replace(
html.match(new RegExp(`<meta\\s*name="${metaName}"[^>]+>`, "g"))[0],
......@@ -186,11 +205,7 @@ function createPages(rootdir, destdir) {
fs.mkdirSync(targetDirPath);
}
const b = browserify();
b.add(fPath)
.bundle()
.pipe(fs.createWriteStream(`${targetDirPath}/${p}.js`));
build_bundle(fPath, `${targetDirPath}/${p}.js`);
const page = fs.createWriteStream(`${targetDirPath}/index.html`);
const pageMeta = JSON.parse(fs.readFileSync(`${fPath}/meta.json`, "utf-8"));
......@@ -219,4 +234,4 @@ function createPages(rootdir, destdir) {
}
}
createPages(`${curDir}/src/pages`, `${curDir}/public`);
createPages(`${_dir}/src/pages`, `${_dir}/public`);
This diff is collapsed.
......@@ -5,8 +5,9 @@
"main": "src/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"style": "sass --watch ./src:public/style",
"build": "node build.js"
"style": "sass --watch ./src/style.scss ./public/style/style.css --style=compressed",
"build": "node build.js",
"build-prod": "node build.js prod"
},
"repository": "https://gitlab.com/peter_rabbit/kuadrado-website",
"author": "Kuadrado",
......@@ -17,6 +18,7 @@
},
"devDependencies": {
"browserify": "^17.0.0",
"sass": "^1.32.0"
"sass": "^1.32.0",
"uglify-js": "^3.13.10"
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Error: Undefined variable.
* ,
* 22 | color: $medium_grey;
* | ^^^^^^^^^^^^
* '
* src/home-page-components/news-articles.scss 22:28 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Undefined variable.\a \2577 \a 22 \2502 color: $medium_grey;\a \2502 ^^^^^^^^^^^^\a \2575 \a src/home-page-components/news-articles.scss 22:28 root stylesheet";
}
/* Error: Undefined mixin.
* ,
* 5 | @include flex-center-col;
* | ^^^^^^^^^^^^^^^^^^^^^^^^
* '
* src/home-page-components/whoami.scss 5:9 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Undefined mixin.\a \2577 \a 5 \2502 @include flex-center-col;\a \2502 ^^^^^^^^^^^^^^^^^^^^^^^^\a \2575 \a src/home-page-components/whoami.scss 5:9 root stylesheet";
}
/* Error: Undefined variable.
* ,
* 7 | color: $light_2;
* | ^^^^^^^^
* '
* src/homepage.scss 7:16 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Undefined variable.\a \2577 \a 7 \2502 color: $light_2;\a \2502 ^^^^^^^^\a \2575 \a src/homepage.scss 7:16 root stylesheet";
}
/* Error: Undefined variable.
* ,
* 25 | background-color: $yellow_2;
* | ^^^^^^^^^
* '
* src/pages/education/education.scss 25:27 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Undefined variable.\a \2577 \a 25 \2502 background-color: $yellow_2;\a \2502 ^^^^^^^^^\a \2575 \a src/pages/education/education.scss 25:27 root stylesheet";
}
/*# sourceMappingURL=game-studio-club.css.map */
/* Error: Undefined variable.
* ,
* 15 | color: $light_2;
* | ^^^^^^^^
* '
* src/pages/games/games.scss 15:28 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Undefined variable.\a \2577 \a 15 \2502 color: $light_2;\a \2502 ^^^^^^^^\a \2575 \a src/pages/games/games.scss 15:28 root stylesheet";
}
/* Error: Undefined variable.
* ,
* 11 | color: $light_2;
* | ^^^^^^^^
* '
* src/pages/software-development/software-development.scss 11:24 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Undefined variable.\a \2577 \a 11 \2502 color: $light_2;\a \2502 ^^^^^^^^\a \2575 \a src/pages/software-development/software-development.scss 11:24 root stylesheet";
}
/*# sourceMappingURL=story-logic-app.css.map */
This diff is collapsed.
/*# sourceMappingURL=theme.css.map */
......@@ -371,6 +371,7 @@ main {
padding: 20px 0 10px;
@include page-contents-center;
}
@import "./homepage.scss";
@import "./pages/education/education.scss";
@import "./pages/games/games.scss";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment