@lisergia/cli 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/.eslintrc.js +4 -0
  2. package/index.js +132 -0
  3. package/package.json +29 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['@lisergia/config-eslint/index.js'],
4
+ }
package/index.js ADDED
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('dotenv').config()
4
+
5
+ const autoprefixer = require('autoprefixer')
6
+ const browsersync = require('rollup-plugin-browsersync')
7
+ const commonjs = require('@rollup/plugin-commonjs')
8
+ const copy = require('rollup-plugin-copy')
9
+ const glslify = require('rollup-plugin-glslify')
10
+ const { nodeResolve } = require('@rollup/plugin-node-resolve')
11
+ const postcss = require('postcss')
12
+ const replace = require('@rollup/plugin-replace')
13
+ const scss = require('rollup-plugin-scss')
14
+ const svg = require('rollup-plugin-svg-icons')
15
+ const terser = require('@rollup/plugin-terser')
16
+ const typescript = require('@rollup/plugin-typescript')
17
+ const { visualizer } = require('rollup-plugin-visualizer')
18
+
19
+ const path = require('path')
20
+ const rollup = require('rollup')
21
+
22
+ const [type] = process.argv.slice(2)
23
+
24
+ const root = path.resolve()
25
+
26
+ const configuration = {
27
+ root: path.join(root),
28
+ src: path.join(root, 'src'),
29
+ build: path.join(root, 'build'),
30
+ }
31
+
32
+ const production = type == 'build'
33
+
34
+ const config = {
35
+ input: path.join(configuration.src, 'app/index.ts'),
36
+ output: {
37
+ file: path.join(configuration.build, 'bundle.js'),
38
+ format: 'cjs',
39
+ sourcemap: !production,
40
+ },
41
+ plugins: [
42
+ replace({
43
+ preventAssignment: true,
44
+
45
+ 'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
46
+ }),
47
+
48
+ commonjs(),
49
+
50
+ copy({
51
+ flatten: true,
52
+ targets: [
53
+ {
54
+ dest: configuration.build,
55
+ rename: (name, extension, fullPath) => fullPath.replace(path.join(configuration.src, 'shared'), ''),
56
+ src: `${path.join(configuration.src, 'shared')}/**`,
57
+ },
58
+ ],
59
+ verbose: true,
60
+ }),
61
+
62
+ glslify({
63
+ compress: production,
64
+ }),
65
+
66
+ nodeResolve(),
67
+
68
+ scss({
69
+ fileName: 'bundle.css',
70
+ outputStyle: 'compressed',
71
+ processor: () => postcss([autoprefixer()]),
72
+ silenceDeprecations: ['color-functions', 'global-builtin', 'import', 'legacy-js-api', 'slash-div'],
73
+ watch: path.join(configuration.src, 'styles'),
74
+ }),
75
+
76
+ svg({
77
+ inputFolder: path.join(configuration.src, 'sprites'),
78
+ output: path.join(configuration.build, 'bundle.svg'),
79
+ }),
80
+
81
+ typescript({
82
+ compilerOptions: {
83
+ lib: ['DOM', 'ESNext'],
84
+ target: 'ESNext',
85
+ },
86
+ include: ['**/*.ts'],
87
+ exclude: ['utilities/**/*.ts', 'router/**/*.ts', '*.ts'],
88
+ tsconfig: false,
89
+ }),
90
+
91
+ !production &&
92
+ browsersync({
93
+ port: process.env.BROWSERSYNC_PORT ?? 3030,
94
+ proxy: process.env.BROWSERSYNC_PROXY ?? 'localhost:3000',
95
+ files: [
96
+ {
97
+ match: [`${path.join(configuration.root, 'views')}/**`],
98
+ fn: function (event, file) {
99
+ this.reload()
100
+ },
101
+ },
102
+ ],
103
+ }),
104
+
105
+ production && terser(),
106
+
107
+ visualizer(),
108
+ ],
109
+ preserveSymlinks: true,
110
+ }
111
+
112
+ if (production) {
113
+ ;(async () => {
114
+ const bundle = await rollup.rollup(config)
115
+
116
+ await bundle.write({
117
+ file: config.output.file,
118
+ })
119
+ })()
120
+ } else {
121
+ const watcher = rollup.watch(config)
122
+
123
+ watcher.on('event', ({ result }) => {
124
+ if (result) {
125
+ result.close()
126
+ }
127
+ })
128
+
129
+ watcher.on('change', (id) => {
130
+ console.log('File refreshed', id)
131
+ })
132
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@lisergia/cli",
3
+ "version": "0.0.0",
4
+ "bin": {
5
+ "lisergia": "index.js"
6
+ },
7
+ "dependencies": {
8
+ "@lisergia/config-eslint": "*",
9
+ "@lisergia/config-tsconfig": "*",
10
+ "@rollup/plugin-commonjs": "^28.0.1",
11
+ "@rollup/plugin-node-resolve": "^15.3.0",
12
+ "@rollup/plugin-replace": "^6.0.1",
13
+ "@rollup/plugin-terser": "^0.4.4",
14
+ "@rollup/plugin-typescript": "^12.1.1",
15
+ "autoprefixer": "^10.4.20",
16
+ "dotenv": "^16.5.0",
17
+ "include-media": "^2.0.0",
18
+ "postcss": "^8.4.49",
19
+ "rollup": "^4.28.1",
20
+ "rollup-plugin-browsersync": "^1.3.3",
21
+ "rollup-plugin-copy": "^3.5.0",
22
+ "rollup-plugin-glslify": "^1.3.1",
23
+ "rollup-plugin-scss": "^4.0.0",
24
+ "rollup-plugin-svg-icons": "^2.1.2",
25
+ "rollup-plugin-typescript2": "^0.36.0",
26
+ "rollup-plugin-visualizer": "^5.12.0",
27
+ "sass": "^1.82.0"
28
+ }
29
+ }