Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rollup.config.js - github.com/spookey/slick.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37faf8373918f0969cb49b42f88e52007edd577b (plain)
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
95
96
97
import copier from 'rollup-plugin-copier';
import cssdiscard from 'postcss-discard-comments';
import cssimport from 'postcss-import';
import cssprefixer from 'autoprefixer';
import cssurl from 'postcss-url';
import path from 'path';
import postcss from 'rollup-plugin-postcss';
import typescript from 'rollup-plugin-typescript2';
import { terser } from 'rollup-plugin-terser';


const devel = () => [
    'dev', 'devel', 'development'
].includes(process.env.BUILD);

const NODE_M = path.normalize(path.join(
  __dirname, 'node_modules',
));
const SOURCES = path.normalize(path.join(
  __dirname, '_assets',
));
const ASSETS = path.normalize(path.join(
  __dirname, 'assets',
));
const STATIC = path.normalize(path.join(
  __dirname, 'static',
));

const assetStyle = () => {
  return {
    input: path.join(SOURCES, '_style.css'),
    output: {
      file: path.join(ASSETS, 'style.css'),
      format: 'system',
    },
    plugins: [
      postcss({
        plugins: [
          cssimport(),
          cssurl({
            url: 'copy',
            assetsPath: path.join(STATIC, 'assets', 'fonts'),
            useHash: true,
          }),
          cssurl({
            url: (asset) => path.relative(
              STATIC, path.join(NODE_M, asset.url)
            ),
          }),
          cssprefixer(),
          cssdiscard({
            removeAll: true,
          }),
        ],
        extract: true,
        minimize: !devel(),
        sourceMap: (devel() ? 'inline' : false),
      }),
      copier({
        items: [{
          src: path.join(NODE_M, 'purecss', 'LICENSE'),
          dest: path.join(STATIC, 'assets', 'license-purecss'),
        }, {
          src: path.join(NODE_M, 'source-code-pro', 'LICENSE.md'),
          dest: path.join(STATIC, 'assets', 'license-source-code-pro.md'),
        }, {
          src: path.join(NODE_M, 'source-sans-pro', 'LICENSE.md'),
          dest: path.join(STATIC, 'assets', 'license-source-sans-pro.md'),
        }, {
          src: path.join(NODE_M, 'source-serif-pro', 'LICENSE.md'),
          dest: path.join(STATIC, 'assets', 'license-source-serif-pro.md'),
        }],
      }),
    ],
  };
};


const assetScript = () => {
  return {
    input: path.join(SOURCES, '_script.ts'),
    output: {
      file: path.join(ASSETS, 'script.js'),
      format: 'iife',
    },
    plugins: [
      typescript(),
      (devel() ? null : terser()),
    ],
  };
};


export default [
  assetStyle(),
  assetScript(),
];