2019-01-20 00:17:54 +00:00
|
|
|
|
import os from 'os';
|
2019-04-14 21:31:56 +00:00
|
|
|
|
// import path from 'pasth';
|
2019-01-26 22:00:37 +00:00
|
|
|
|
import fs from 'fs';
|
2019-01-20 00:17:54 +00:00
|
|
|
|
|
2019-01-13 13:15:11 +00:00
|
|
|
|
import resolve from 'rollup-plugin-node-resolve';
|
|
|
|
|
import commonjs from 'rollup-plugin-commonjs';
|
2019-01-17 12:48:09 +00:00
|
|
|
|
import postcss from 'rollup-plugin-postcss';
|
2019-01-20 00:17:54 +00:00
|
|
|
|
import { terser } from "rollup-plugin-terser";
|
2019-01-26 22:00:37 +00:00
|
|
|
|
import replace from 'rollup-plugin-replace';
|
2019-01-17 12:48:09 +00:00
|
|
|
|
|
|
|
|
|
import postcss_import from 'postcss-import';
|
2019-01-20 00:56:40 +00:00
|
|
|
|
import postcss_copy from 'postcss-copy';
|
2019-01-13 13:15:11 +00:00
|
|
|
|
|
2019-01-20 23:22:09 +00:00
|
|
|
|
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' ]
|
|
|
|
|
}),
|
|
|
|
|
|
2019-01-26 22:00:37 +00:00
|
|
|
|
|
|
|
|
|
replace({
|
|
|
|
|
exclude: 'node_modules/**',
|
|
|
|
|
values: {
|
|
|
|
|
"__BUILD_DATE__": () => new Date().toISOString(),
|
|
|
|
|
"__VERSION__": fs.readFileSync("version", "utf8").trim()
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
|
2019-01-20 23:22:09 +00:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-13 13:15:11 +00:00
|
|
|
|
export default {
|
2019-01-13 13:22:13 +00:00
|
|
|
|
input: 'client_src/js/index.mjs',
|
2019-01-13 13:15:11 +00:00
|
|
|
|
output: {
|
2019-01-17 13:56:25 +00:00
|
|
|
|
file: 'app/app.js',
|
2019-01-20 15:18:29 +00:00
|
|
|
|
format: 'esm'
|
2019-01-13 13:15:11 +00:00
|
|
|
|
},
|
2019-01-20 23:22:09 +00:00
|
|
|
|
plugins
|
2019-01-13 13:15:11 +00:00
|
|
|
|
};
|