1
1
# yii2-optimizer
2
2
> ** Help is welcome!**
3
- The project is under development, so you can commit to the master branch . You can also write about errors found in "issues".
3
+ The project is under development. You can write about errors found in "issues".
4
4
5
5
Tool for automatic assets optimization. Work with CSS & ; JS files. This tool created as Yii2 extension. Refactoring in progress...
6
6
@@ -40,50 +40,39 @@ Tool for automatic assets optimization. Work with CSS & JS files. This tool
40
40
...
41
41
'optimizer' => [
42
42
'class' => 'alexshul\optimizer\Module',
43
+ 'assetsConfigFile' => __FILE__,
43
44
'assetsClearStyles' => false,
44
45
'assetsClearScripts' => false,
45
46
'assetsAddLoader' => true,
46
- 'assetsMinifyLoader' => true,
47
- 'assetsToWatch' => [
48
- 'My styles bundle' => [
49
- 'condition' => false,
50
- 'type' => 'link',
51
- 'files' => [
52
- 'site' => [
53
- 'pathDirectory' => 'assets/data/css/site/',
54
- 'fileName' => 'site.css',
55
- 'version' => 'v1'
56
- ],
57
- ],
58
- 'dest' => 'assets/styles.min.css',
59
- 'autoload' => false
60
- ],
61
- 'Promise fallback' => [
62
- 'condition' => 'typeof Promise !== \'function\'',
63
- 'dest' => 'assets/fallbacks/promise.min.js'
64
- ],
65
- 'fetch fallback' => [
66
- 'condition' => 'typeof fetch !== \'function\'',
67
- 'dest' => 'assets/fallbacks/fetch.umd.js'
68
- ],
69
- 'My scripts bundle' => [
70
- 'condition' => false,
71
- 'type' => 'script',
72
- 'files' => [
73
- 'main' => [
74
- 'pathDirectory' => 'assets/data/js/main/',
75
- 'fileName' => 'main.js',
76
- 'version' => 'v2'
77
- ],
78
- 'hello' => [
79
- 'pathDirectory' => 'assets/data/js/hello/',
80
- 'fileName' => 'hello.js',
81
- 'version' => 'v1'
82
- ],
83
- ],
84
- 'dest' => 'assets/scripts.min.js'
85
- ],
86
- ],
47
+ 'assetsMinifyLoader' => false,
48
+ 'assetsToWatch' => [
49
+ 'styles before' => [
50
+ 'src' => [
51
+ 'assets/src/css/site/site.css'
52
+ ],
53
+ 'dest' => 'assets/styles.min.css',
54
+ 'autoload' => false,
55
+ 'preload' => true,
56
+ 'showPage' => true
57
+ ],
58
+ 'Promise fallback' => [
59
+ 'condition' => 'typeof Promise !== \'function\'',
60
+ 'dest' => 'assets/fallbacks/promise.min.js'
61
+ ],
62
+ 'fetch fallback' => [
63
+ 'condition' => 'typeof fetch !== \'function\'',
64
+ 'dest' => 'assets/fallbacks/fetch.umd.js'
65
+ ],
66
+ 'My scripts bundle' => [
67
+ 'type' => 'script',
68
+ 'src' => [
69
+ 'assets/src/js/file_one.js',
70
+ 'assets/src/js/file_two.js',
71
+ 'assets/src/js/file_three.js'
72
+ ],
73
+ 'dest' => 'assets/scripts.min.js'
74
+ ],
75
+ ]
87
76
],
88
77
],
89
78
```
@@ -107,42 +96,19 @@ Extension has options:
107
96
If true - minifies loader javascript before adding it to the page.
108
97
- ` assetsToWatch ` *** {array}*** * (default: empty array)*
109
98
110
- Example directory structure:
111
- ```
112
- data
113
- ├─── css
114
- │ └─── site
115
- │ ├─── v1
116
- │ │ └── site.css
117
- │ └─── v2
118
- │ └── site.css
119
- └─── js
120
- ├─── main
121
- │ ├─── v1
122
- │ │ └── main.js
123
- │ └─── v2
124
- │ └── main.js
125
- └─── hello
126
- ├─── v1
127
- │ └── hello.js
128
- └─── v2
129
- └── hello.js
130
- ```
131
- Array with keys = "random semantic name for your asset", and values = "array with options". Example:
132
- ```
133
-
134
- 'My styles bundle' => [ // Name of your asset
135
- 'condition' => false, // Condition, which allows loader attach link with asset to the page head.
136
- 'type' => 'link', // Name of tag element with link to asset, which loader script will attach to the page head.
137
- 'files' => [ // Array of files for to watch and combine+minify
138
- 'site' => [ // File name asset
139
- 'pathDirectory' => 'assets/data/css/site/', // Source path directory
140
- 'fileName' => 'site.css', // File name asset
141
- 'version' => 'v1' // Version name
142
- ],
143
- ],
144
- 'dest' => 'assets/styles.min.css', // (Required) Destination file for your asset.
145
- 'autoload' => false // (Optional) If set to false - this asset will be not included to loader script.
146
- ],
99
+ Array with keys = "random semantic name for your asset", and values = "array with options". Example:
100
+ ```
101
+ 'styles before' => [ // Name of your asset
102
+ 'condition' => '1 == 1', // Condition, which allows loader attach link with asset to the page head.
103
+ 'type' => 'link', // Name of tag element with link to asset, which loader script will attach to the page head.
104
+ 'src' => [ // Array of files for to watch and combine+minify
105
+ 'assets/src/css/site/site.css'
106
+ ],
107
+ 'dest' => 'assets/styles.min.css', // (Required) Destination file for your asset.
108
+ //'autoload' => false,
109
+ 'preload' => true,
110
+ 'showPage' => true,
111
+ 'autoload' => false // (Optional) If set to false - this asset will be not included to loader script.
112
+ ]
147
113
148
114
```
0 commit comments