forked from ConnectedHumber/Air-Quality-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
94 lines (79 loc) · 2.24 KB
/
rollup.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os from 'os';
// import path from 'pasth';
import fs from 'fs';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import { terser } from "rollup-plugin-terser";
import replace from 'rollup-plugin-replace';
import json from 'rollup-plugin-json';
import postcss_import from 'postcss-import';
import postcss_copy from 'postcss-copy';
let plugins = [
resolve({
// use "module" field for ES6 module if possible
module: true, // Default: true
// use "jsnext:main" if possible
// – see https://github.com/rollup/rollup/wiki/jsnext:main
jsnext: true, // Default: false
// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true
// some package.json files have a `browser` field which
// specifies alternative files to load for people bundling
// for the browser. If that's you, use this option, otherwise
// pkg.browser will be ignored
browser: true, // Default: false
// not all files you want to resolve are .js files
extensions: ['.mjs', '.js', '.jsx', '.json'], // Default: [ '.mjs', '.js', '.json', '.node' ]
}),
json({
}),
replace({
exclude: 'node_modules/**',
values: {
"__BUILD_DATE__": () => new Date().toISOString(),
"__VERSION__": fs.readFileSync("version", "utf8").trim()
}
}),
commonjs({
}),
postcss({
plugins: [
postcss_import({}),
postcss_copy({
dest: "app",
template: "resources/[name].[ext]"
})
// postcss_url(),
// postcss_url({
// url: "copy",
// basePath: path.resolve("."),
// assetPath: "resources"
// })
],
// Save it to a .css file - we'll reference it ourselves thank you
// very much
extract: true,
sourceMap: true,
//minimize: true, // Causes an error at the moment for some reason
})
];
if(process.env.NODE_ENV == "production") {
console.log("[config] In production environment - minifying JS");
plugins.push(terser({
numWorkers: os.cpus().length,
compress: {
ecma: 6
}
}));
}
export default {
input: 'client_src/js/index.mjs',
output: {
file: 'app/app.js',
format: 'esm'
},
plugins
};