cozy-bar 1.17.1

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 (181) hide show
  1. package/.eslintrc.json +7 -0
  2. package/.github/auto-merge.yml +7 -0
  3. package/.nvmrc +1 -0
  4. package/.transifexrc.tpl +4 -0
  5. package/.travis.yml +28 -0
  6. package/.tx/config +8 -0
  7. package/CHANGELOG.md +493 -0
  8. package/CODEOWNERS +2 -0
  9. package/CONTRIBUTING.md +135 -0
  10. package/LICENSE +21 -0
  11. package/README.md +172 -0
  12. package/babel.config.js +3 -0
  13. package/config/aliases/globalReact.js +1 -0
  14. package/config/aliases/globalReactDOM.js +1 -0
  15. package/config/webpack.config.analyzer.js +10 -0
  16. package/config/webpack.config.base.js +61 -0
  17. package/config/webpack.config.dev.js +16 -0
  18. package/config/webpack.config.extract.js +84 -0
  19. package/config/webpack.config.inline-styles.js +82 -0
  20. package/config/webpack.config.jsx.js +14 -0
  21. package/config/webpack.config.prod.js +18 -0
  22. package/config/webpack.js +31 -0
  23. package/config/webpack.vars.js +11 -0
  24. package/dist/cozy-bar.css +9445 -0
  25. package/dist/cozy-bar.css.map +1 -0
  26. package/dist/cozy-bar.js +122668 -0
  27. package/dist/cozy-bar.js.map +1 -0
  28. package/dist/cozy-bar.min.css +9 -0
  29. package/dist/cozy-bar.min.css.map +1 -0
  30. package/dist/cozy-bar.min.js +57 -0
  31. package/dist/cozy-bar.min.js.map +1 -0
  32. package/dist/cozy-bar.mobile.js +123719 -0
  33. package/dist/cozy-bar.mobile.js.map +1 -0
  34. package/dist/cozy-bar.mobile.min.js +57 -0
  35. package/dist/cozy-bar.mobile.min.js.map +1 -0
  36. package/docs/dev.md +20 -0
  37. package/examples/Procfile +3 -0
  38. package/examples/icon.png +0 -0
  39. package/examples/index.html +7 -0
  40. package/examples/index.jsx +122 -0
  41. package/examples/logs.js +3 -0
  42. package/package.json +163 -0
  43. package/postcss.config.js +23 -0
  44. package/public/fonts/Lato-Bold.woff2 +0 -0
  45. package/public/fonts/Lato-Regular.woff2 +0 -0
  46. package/public/fonts.css +13 -0
  47. package/public/icon-type-folder-32.png +0 -0
  48. package/public/index.html +63 -0
  49. package/renovate.json +5 -0
  50. package/src/assets/icons/16/icon-claudy.svg +5 -0
  51. package/src/assets/icons/16/icon-cozy-16.svg +1 -0
  52. package/src/assets/icons/16/icon-cube-16.svg +6 -0
  53. package/src/assets/icons/16/icon-logout-16.svg +3 -0
  54. package/src/assets/icons/16/icon-magnifier-16.svg +6 -0
  55. package/src/assets/icons/16/icon-people-16.svg +3 -0
  56. package/src/assets/icons/16/icon-phone-16.svg +3 -0
  57. package/src/assets/icons/16/icon-question-mark-16.svg +3 -0
  58. package/src/assets/icons/16/icon-storage-16.svg +3 -0
  59. package/src/assets/icons/24/icon-arrow-left.svg +3 -0
  60. package/src/assets/icons/32/icon-claudy.svg +1 -0
  61. package/src/assets/icons/apps/icon-collect.svg +25 -0
  62. package/src/assets/icons/apps/icon-drive.svg +17 -0
  63. package/src/assets/icons/apps/icon-market-soon.svg +25 -0
  64. package/src/assets/icons/apps/icon-photos.svg +19 -0
  65. package/src/assets/icons/apps/icon-soon.svg +21 -0
  66. package/src/assets/icons/apps/icon-store.svg +19 -0
  67. package/src/assets/icons/claudyActions/icon-bills.svg +6 -0
  68. package/src/assets/icons/claudyActions/icon-laptop.svg +7 -0
  69. package/src/assets/icons/claudyActions/icon-phone.svg +8 -0
  70. package/src/assets/icons/claudyActions/icon-question-mark.svg +6 -0
  71. package/src/assets/icons/comingsoon/icon-bank.svg +12 -0
  72. package/src/assets/icons/comingsoon/icon-sante.svg +12 -0
  73. package/src/assets/icons/comingsoon/icon-store.svg +6 -0
  74. package/src/assets/icons/icon-cozy.svg +3 -0
  75. package/src/assets/icons/icon-shield.svg +3 -0
  76. package/src/assets/icons/spinner.svg +4 -0
  77. package/src/assets/sprites/icon-apps.svg +1 -0
  78. package/src/assets/sprites/icon-cozy-home.svg +16 -0
  79. package/src/components/Apps/AppItem.jsx +117 -0
  80. package/src/components/Apps/AppItemPlaceholder.jsx +12 -0
  81. package/src/components/Apps/AppNavButtons.jsx +88 -0
  82. package/src/components/Apps/AppsContent.jsx +89 -0
  83. package/src/components/Apps/ButtonCozyHome.jsx +30 -0
  84. package/src/components/Apps/ButtonCozyHome.spec.jsx +53 -0
  85. package/src/components/Apps/IconCozyHome.jsx +24 -0
  86. package/src/components/Apps/index.jsx +81 -0
  87. package/src/components/Banner.jsx +41 -0
  88. package/src/components/Bar.jsx +293 -0
  89. package/src/components/Bar.spec.jsx +133 -0
  90. package/src/components/Claudy.jsx +81 -0
  91. package/src/components/Drawer.jsx +227 -0
  92. package/src/components/Drawer.spec.jsx +98 -0
  93. package/src/components/SearchBar.jsx +358 -0
  94. package/src/components/Settings/SettingsContent.jsx +145 -0
  95. package/src/components/Settings/StorageData.jsx +29 -0
  96. package/src/components/Settings/helper.js +8 -0
  97. package/src/components/Settings/index.jsx +218 -0
  98. package/src/components/SupportModal.jsx +59 -0
  99. package/src/components/__snapshots__/Bar.spec.jsx.snap +302 -0
  100. package/src/config/claudyActions.yaml +14 -0
  101. package/src/config/persistWhitelist.yaml +2 -0
  102. package/src/dom.js +80 -0
  103. package/src/index.jsx +235 -0
  104. package/src/index.spec.jsx +34 -0
  105. package/src/lib/api/helpers.js +13 -0
  106. package/src/lib/api/index.jsx +145 -0
  107. package/src/lib/exceptions.js +89 -0
  108. package/src/lib/expiringMemoize.js +13 -0
  109. package/src/lib/icon.js +77 -0
  110. package/src/lib/importIcons.js +14 -0
  111. package/src/lib/intents.js +16 -0
  112. package/src/lib/logger.js +6 -0
  113. package/src/lib/middlewares/appsI18n.js +57 -0
  114. package/src/lib/realtime.js +43 -0
  115. package/src/lib/reducers/apps.js +175 -0
  116. package/src/lib/reducers/apps.spec.js +59 -0
  117. package/src/lib/reducers/content.js +50 -0
  118. package/src/lib/reducers/context.js +83 -0
  119. package/src/lib/reducers/index.js +73 -0
  120. package/src/lib/reducers/locale.js +22 -0
  121. package/src/lib/reducers/settings.js +111 -0
  122. package/src/lib/reducers/theme.js +48 -0
  123. package/src/lib/reducers/unserializable.js +26 -0
  124. package/src/lib/stack-client.js +401 -0
  125. package/src/lib/stack.js +79 -0
  126. package/src/lib/store/index.js +54 -0
  127. package/src/locales/de.json +57 -0
  128. package/src/locales/en.json +57 -0
  129. package/src/locales/es.json +57 -0
  130. package/src/locales/fr.json +57 -0
  131. package/src/locales/it.json +57 -0
  132. package/src/locales/ja.json +57 -0
  133. package/src/locales/nl_NL.json +57 -0
  134. package/src/locales/pl.json +57 -0
  135. package/src/locales/ru.json +57 -0
  136. package/src/locales/sq.json +57 -0
  137. package/src/locales/zh_CN.json +57 -0
  138. package/src/proptypes/index.js +10 -0
  139. package/src/queries/index.js +16 -0
  140. package/src/styles/apps.css +248 -0
  141. package/src/styles/banner.css +64 -0
  142. package/src/styles/bar.css +106 -0
  143. package/src/styles/base.css +41 -0
  144. package/src/styles/claudy.css +99 -0
  145. package/src/styles/drawer.css +126 -0
  146. package/src/styles/index.styl +33 -0
  147. package/src/styles/indicators.css +58 -0
  148. package/src/styles/nav.css +81 -0
  149. package/src/styles/navigation_item.css +39 -0
  150. package/src/styles/searchbar.css +158 -0
  151. package/src/styles/settings.css +44 -0
  152. package/src/styles/storage.css +22 -0
  153. package/src/styles/supportModal.css +20 -0
  154. package/src/styles/theme.styl +25 -0
  155. package/test/__mocks__/fileMock.js +3 -0
  156. package/test/__snapshots__/index.spec.js.snap +41 -0
  157. package/test/components/AppItem.spec.jsx +113 -0
  158. package/test/components/AppsContent.spec.jsx +116 -0
  159. package/test/components/Settings/helper.spec.js +23 -0
  160. package/test/components/__snapshots__/AppsContent.spec.jsx.snap +90 -0
  161. package/test/index.spec.js +24 -0
  162. package/test/jestLib/I18n.js +15 -0
  163. package/test/jestLib/setup.js +14 -0
  164. package/test/lib/__snapshots__/api.spec.jsx.snap +67 -0
  165. package/test/lib/__snapshots__/stack.spec.js.snap +3 -0
  166. package/test/lib/api.spec.jsx +142 -0
  167. package/test/lib/mockStackClient.js +7 -0
  168. package/test/lib/stack-client/stack-client.appiconprops.spec.js +65 -0
  169. package/test/lib/stack-client/stack-client.compare.spec.js +20 -0
  170. package/test/lib/stack-client/stack-client.cozyfetchjson.spec.js +46 -0
  171. package/test/lib/stack-client/stack-client.cozyurl.spec.js +29 -0
  172. package/test/lib/stack-client/stack-client.getapp.spec.js +72 -0
  173. package/test/lib/stack-client/stack-client.getapps.spec.js +72 -0
  174. package/test/lib/stack-client/stack-client.getcontext.spec.js +96 -0
  175. package/test/lib/stack-client/stack-client.getstoragedata.spec.js +85 -0
  176. package/test/lib/stack-client/stack-client.init.spec.js +56 -0
  177. package/test/lib/stack-client/stack-client.intents.spec.js +27 -0
  178. package/test/lib/stack-client/stack-client.logout.spec.js +40 -0
  179. package/test/lib/stack.spec.js +60 -0
  180. package/test/store/__snapshots__/index.spec.js.snap +14 -0
  181. package/test/store/index.spec.js +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Cozy.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ [![Travis build status shield](https://img.shields.io/travis/cozy/cozy-bar/master.svg)](https://travis-ci.org/cozy/cozy-bar)
2
+ [![NPM release version shield](https://img.shields.io/npm/v/cozy-bar.svg)](https://www.npmjs.com/package/cozy-bar)
3
+ [![NPM Licence shield](https://img.shields.io/npm/l/cozy-bar.svg)](https://github.com/cozy/cozy-bar/blob/master/LICENSE)
4
+
5
+
6
+ [Cozy] Bar Library
7
+ ==================
8
+
9
+
10
+ What's Cozy?
11
+ ------------
12
+
13
+ ![Cozy Logo](https://cdn.rawgit.com/cozy/cozy-guidelines/master/templates/cozy_logo_small.svg)
14
+
15
+ [Cozy] is a platform that brings all your web services in the same private space. With it, your webapps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one's tracking you.
16
+
17
+
18
+ What's cozy-bar.js?
19
+ ----------------
20
+
21
+ `cozy-bar.js` is a javascript library made by Cozy. It enables the _CozyBar_ component in your application. This component is a banner on the top of your application, responsible of cross-apps navigation, user facilities, intents, etc.
22
+
23
+
24
+ Use
25
+ ---
26
+
27
+ `cozy-bar.js` is an asset directly served by the [cozy-stack](https://github.com/cozy/cozy-stack). To use it, simply add `<script src="/js/cozy-bar.js" defer></script>` in the `<head>` section of the `index.html` of your application. It exposes an API behind the `window.cozy.bar` namespace, that let you interact with the _CozyBar_ itself.
28
+
29
+ The library requires your markup to contain an element with `role=application` and attributes `data-cozy-domain` and `data-cozy-token`. The DOM of the banner will be added before this element.
30
+
31
+
32
+ Once you have the library included in your application, starts by intialize it in your app bootstrap:
33
+
34
+ ```js
35
+ window.cozy.bar.init({
36
+ appName: MY_APP_NAME,
37
+ appNamePrefix: MY_APP_NAME_PREFIX
38
+ iconPath: PATH_TO_SVG_ICON,
39
+ lang: LOCALE
40
+ })
41
+ ```
42
+
43
+ `appName` param in hash is mandatory when `appNamePrefix`, `lang` and `iconPath` are optionals. If not passed, their values are detected into the DOM:
44
+
45
+ - `appNamePrefix` is extracted from the manifest. Originally used for apps maintained by Cozy Cloud teams.
46
+ - `lang` is extracted from the `lang` attribute of the `<html>` tag. Defaults to 'en'
47
+ - `iconPath` uses the favicon 32px. Defaults to a blank GIF
48
+
49
+ Help link
50
+ ---
51
+ Help link is defined in your Cozy's [configuration file](https://github.com/cozy/cozy-stack/blob/master/docs/config.md#main-configuration-file), in the `context` section. See the `cozy.example.yaml` file [provided by the stack](https://github.com/cozy/cozy-stack/blob/master/cozy.example.yaml#L80).
52
+
53
+ Coming Soon application
54
+ ---
55
+ Coming Soon applications (or apps) are defined in your Cozy's [configuration file](https://github.com/cozy/cozy-stack/blob/master/docs/config.md#main-configuration-file). See the `cozy.example.yaml` file [provided by the stack](https://github.com/cozy/cozy-stack/blob/master/cozy.example.yaml#L80).
56
+
57
+ Claudy actions list
58
+ ---
59
+ Claudy actions are declared in `src/config/claudy.yaml` with a slug as property name and some options (icon name and link options for example). The slugs list that will be used for Claudy is defined in your Cozy's [configuration file](https://github.com/cozy/cozy-stack/blob/master/docs/config.md#main-configuration-file). See the `cozy.example.yaml` file [provided by the stack](https://github.com/cozy/cozy-stack/blob/master/cozy.example.yaml#L101).
60
+ If no `claudy_actions` property is defined in the configuration, Claudy won't be displayed.
61
+
62
+ Customizing the content of the bar
63
+ ---
64
+ From within your app, you can decide to take over certain areas of the cozy-bar. This might especially be useful on mobile where the area it occupies is prime real estate — we generally don't recommend to use this option on larger screen resolutions.
65
+
66
+ The bar is divided in 3 areas that you can control individually : left, center and right:
67
+
68
+ ![cozy-bar-triplet](https://user-images.githubusercontent.com/2261445/33609298-de4d379e-d9c7-11e7-839d-f5ab6155c902.png)
69
+
70
+ To do this, you need to call one of the 3 exposed functions like this:
71
+
72
+ ```jsx
73
+ const setBarLeft = cozy.bar.setBarLeft
74
+ setBarLeft('<div>Hello!</div>')
75
+ // there's also cozy.bar.setBarCenter and cozy.bar.setBarRight
76
+ ```
77
+
78
+ If you're using React, you can use the component form instead:
79
+
80
+ ```jsx
81
+ const { BarLeft, BarCenter, BarRight } = cozy.bar
82
+
83
+ // then, somewhere in a render function
84
+ <BarLeft>
85
+ <div>Hello!</div>
86
+ </BarLeft>
87
+ ```
88
+
89
+ If you're using Redux and include a connected component in the bar, it might not work as expected since inside `<BarLeft>` and friends, the redux store is different.
90
+
91
+ ```jsx
92
+ const MyConnectedComponent = connect(mapStateToProps, mapDispatchToProps, MyComponent)
93
+
94
+ // … in a render function
95
+ <BarLeft>
96
+ <MyConnectedComponent /> // … you won't get the expected props from redux
97
+ </BarLeft>
98
+ ```
99
+
100
+ Instead, you can do something like this:
101
+
102
+ ```jsx
103
+ const MyWrappedComponent = (props) => (
104
+ <BarLeft>
105
+ <MyComponent {...props} />
106
+ </BarLeft>
107
+ )
108
+
109
+ const MyConnectedComponent = connect(mapStateToProps, mapDispatchToProps, MyWrappedComponent)
110
+
111
+ // …in a render function
112
+ <MyConnectedComponent />
113
+ ```
114
+
115
+ Change theme bar
116
+ ---
117
+
118
+ It's possible to update theme on the cozy-bar with `setTheme` function.
119
+
120
+ ```jsx
121
+ const { setTheme } = cozy.bar
122
+
123
+ setTheme('default')
124
+ setTheme('primary')
125
+ ```
126
+
127
+ Contribute
128
+ ----------
129
+
130
+ If you want to work on cozy-client-js itself and submit code modifications, feel free to open pull-requests! See the [contributing guide][contribute] for more information about this repository structure, testing, linting and how to properly open pull-requests.
131
+
132
+
133
+ Community
134
+ ---------
135
+
136
+ ### Maintainer
137
+
138
+ The lead maintainer for cozy-bar.js is [@CPatchane](https://github.com/CPatchane), send him/her a :beers: to say hello!
139
+
140
+
141
+ ### Get in touch
142
+
143
+ You can reach the Cozy Community by:
144
+
145
+ - Chatting with us on IRC [#cozycloud on Freenode][freenode]
146
+ - Posting on our [Forum][forum]
147
+ - Posting issues on the [Github repos][github]
148
+ - Say Hi! on [Twitter][twitter]
149
+
150
+
151
+ Licence
152
+ -------
153
+
154
+ cozy-bar.js is developed by Cozy Cloud and distributed under the [MIT].
155
+
156
+
157
+
158
+ [cozy]: https://cozy.io "Cozy Cloud"
159
+ [setup]: https://dev.cozy.io/#set-up-the-development-environment "Cozy dev docs: Set up the Development Environment"
160
+ [doctypes]: https://dev.cozy.io/#main-document-types
161
+ [bill-doctype]: https://github.com/cozy-labs/konnectors/blob/master/server/models/bill.coffee
162
+ [konnector-doctype]: https://github.com/cozy-labs/konnectors/blob/master/server/models/konnector.coffee
163
+ [konnectors]: https://github.com/cozy-labs/konnectors
164
+ [MIT]: https://opensource.org/licenses/MIT
165
+ [contribute]: CONTRIBUTING.md
166
+ [freenode]: http://webchat.freenode.net/?randomnick=1&channels=%23cozycloud&uio=d4
167
+ [forum]: https://forum.cozy.io/
168
+ [github]: https://github.com/cozy/
169
+ [twitter]: https://twitter.com/cozycloud
170
+ [mocha]: https://mochajs.org/
171
+ [should]: npmjs.com/package/should
172
+ [checkbox]: https://help.github.com/articles/basic-writing-and-formatting-syntax/#task-lists
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: ['cozy-app']
3
+ }
@@ -0,0 +1 @@
1
+ module.exports = window.React || require('my-react')
@@ -0,0 +1 @@
1
+ module.exports = window.ReactDOM || require('my-react-dom')
@@ -0,0 +1,10 @@
1
+ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
2
+ .BundleAnalyzerPlugin
3
+
4
+ module.exports = {
5
+ plugins: [
6
+ new BundleAnalyzerPlugin({
7
+ analyzerPort: 8889
8
+ })
9
+ ]
10
+ }
@@ -0,0 +1,61 @@
1
+ 'use strict'
2
+
3
+ const path = require('path')
4
+ const webpack = require('webpack')
5
+ const pkg = require('../package.json')
6
+
7
+ const SRC_DIR = path.resolve(__dirname, '../src')
8
+
9
+ module.exports = {
10
+ entry: path.resolve(__dirname, '../src/index'),
11
+ output: {
12
+ library: ['cozy', 'bar'],
13
+ libraryTarget: 'umd',
14
+ umdNamedDefine: true
15
+ },
16
+ resolve: {
17
+ extensions: ['.js', '.json', '.yaml', '.jsx'],
18
+ modules: [SRC_DIR, 'node_modules'],
19
+ alias: {
20
+ react: path.resolve(__dirname, 'aliases/globalReact'),
21
+ 'react-dom': path.resolve(__dirname, 'aliases/globalReactDOM')
22
+ }
23
+ },
24
+ devtool: '#source-map',
25
+ module: {
26
+ rules: [
27
+ {
28
+ test: /\.jsx?$/,
29
+ exclude: /node_modules\/(?!(cozy-ui\/react))/,
30
+ loader: 'babel-loader'
31
+ },
32
+ {
33
+ test: /\.yaml$/,
34
+ loaders: ['json-loader', 'yaml-loader']
35
+ },
36
+ {
37
+ test: /\.svg$/,
38
+ include: /icons/,
39
+ exclude: /node_modules/,
40
+ loader: 'url-loader'
41
+ },
42
+ {
43
+ test: /\.svg$/,
44
+ include: /sprites/,
45
+ exclude: /node_modules/,
46
+ loader: 'svg-sprite-loader'
47
+ },
48
+ {
49
+ test: /\.svg$/,
50
+ include: /cozy-ui/,
51
+ loader: 'svg-sprite-loader'
52
+ }
53
+ ]
54
+ },
55
+ plugins: [
56
+ new webpack.ContextReplacementPlugin(/date-fns[/\\]locale$/, /(en|es|fr)/),
57
+ new webpack.DefinePlugin({
58
+ __VERSION__: JSON.stringify(pkg.version)
59
+ })
60
+ ]
61
+ }
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ const webpack = require('webpack')
4
+
5
+ module.exports = {
6
+ mode: 'development',
7
+ plugins: [
8
+ new webpack.DefinePlugin({
9
+ __DEVELOPMENT__: true,
10
+ __PIWIK_SITEID__: 8,
11
+ __PIWIK_SITEID_MOBILE__: 12,
12
+ __PIWIK_DIMENSION_ID_APP__: 1,
13
+ __PIWIK_TRACKER_URL__: JSON.stringify('https://matomo.cozycloud.cc')
14
+ })
15
+ ]
16
+ }
@@ -0,0 +1,84 @@
1
+ 'use strict'
2
+
3
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
4
+ const webpack = require('webpack')
5
+
6
+ module.exports = ({ filename, production }) => ({
7
+ resolve: {
8
+ extensions: ['.styl']
9
+ },
10
+ module: {
11
+ rules: [
12
+ {
13
+ test: /\.styl$/,
14
+ exclude: /cozy-ui\/react/,
15
+ use: [
16
+ MiniCssExtractPlugin.loader,
17
+ {
18
+ loader: 'css-loader',
19
+ options: { importLoaders: 2, sourceMap: true }
20
+ },
21
+ {
22
+ loader: 'postcss-loader',
23
+ options: {
24
+ config: {
25
+ ctx: {
26
+ env: production ? 'production' : 'development'
27
+ }
28
+ },
29
+ sourceMap: true
30
+ }
31
+ },
32
+ {
33
+ loader: 'stylus-loader'
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ test: /\.styl$/,
39
+ include: /cozy-ui\/react/,
40
+ use: [
41
+ MiniCssExtractPlugin.loader,
42
+ {
43
+ loader: 'css-loader',
44
+ options: {
45
+ importLoaders: 2,
46
+ sourceMap: true,
47
+ modules: true,
48
+ localIdentName: 'cozy-ui-bar-[local]--[hash:base64:5]'
49
+ }
50
+ },
51
+ {
52
+ loader: 'postcss-loader',
53
+ options: {
54
+ config: {
55
+ ctx: {
56
+ env: production ? 'production' : 'development'
57
+ }
58
+ },
59
+ sourceMap: true
60
+ }
61
+ },
62
+ {
63
+ loader: 'stylus-loader'
64
+ }
65
+ ]
66
+ }
67
+ ]
68
+ },
69
+ plugins: [
70
+ new MiniCssExtractPlugin({
71
+ // Options similar to the same options in webpackOptions.output
72
+ // both options are optional
73
+ filename: filename('css'),
74
+ chunkFilename: filename('css', '[name].[id]')
75
+ }),
76
+ new webpack.LoaderOptionsPlugin({
77
+ options: {
78
+ stylus: {
79
+ use: [require('cozy-ui/stylus')()]
80
+ }
81
+ }
82
+ })
83
+ ]
84
+ })
@@ -0,0 +1,82 @@
1
+ 'use strict'
2
+
3
+ const webpack = require('webpack')
4
+
5
+ module.exports = ({ production }) => ({
6
+ resolve: {
7
+ extensions: ['.styl']
8
+ },
9
+ module: {
10
+ rules: [
11
+ {
12
+ test: /\.styl$/,
13
+ exclude: /cozy-ui\/react/,
14
+ use: [
15
+ {
16
+ loader: 'style-loader'
17
+ },
18
+ {
19
+ loader: 'css-loader',
20
+ options: { importLoaders: 2 }
21
+ },
22
+ {
23
+ loader: 'postcss-loader',
24
+ options: {
25
+ config: {
26
+ ctx: {
27
+ env: production ? 'production' : 'development'
28
+ }
29
+ },
30
+ sourceMap: true
31
+ }
32
+ },
33
+ {
34
+ loader: 'stylus-loader'
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ test: /\.styl$/,
40
+ include: /cozy-ui\/react/,
41
+ use: [
42
+ {
43
+ loader: 'style-loader',
44
+ options: { sourceMap: true }
45
+ },
46
+ {
47
+ loader: 'css-loader',
48
+ options: {
49
+ importLoaders: 2,
50
+ sourceMap: true,
51
+ modules: true,
52
+ localIdentName: 'cozy-ui-bar-[local]--[hash:base64:5]'
53
+ }
54
+ },
55
+ {
56
+ loader: 'postcss-loader',
57
+ options: {
58
+ config: {
59
+ ctx: {
60
+ env: production ? 'production' : 'development'
61
+ }
62
+ },
63
+ sourceMap: true
64
+ }
65
+ },
66
+ {
67
+ loader: 'stylus-loader'
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ },
73
+ plugins: [
74
+ new webpack.LoaderOptionsPlugin({
75
+ options: {
76
+ stylus: {
77
+ use: [require('cozy-ui/stylus')()]
78
+ }
79
+ }
80
+ })
81
+ ]
82
+ })
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ const webpack = require('webpack')
4
+
5
+ module.exports = {
6
+ // Necessary for cozy-ui during Preact -> React apps transition
7
+ plugins: [
8
+ new webpack.DefinePlugin({
9
+ 'process.env': {
10
+ USE_REACT: 'true'
11
+ }
12
+ })
13
+ ]
14
+ }
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+
3
+ const webpack = require('webpack')
4
+
5
+ module.exports = {
6
+ mode: 'production',
7
+ plugins: [
8
+ new webpack.optimize.OccurrenceOrderPlugin(),
9
+ new webpack.DefinePlugin({
10
+ 'process.env.NODE_ENV': JSON.stringify('production'), // to compile on production mode (redux)
11
+ __DEVELOPMENT__: false,
12
+ __PIWIK_SITEID__: 8,
13
+ __PIWIK_SITEID_MOBILE__: 12,
14
+ __PIWIK_DIMENSION_ID_APP__: 1,
15
+ __PIWIK_TRACKER_URL__: JSON.stringify('https://matomo.cozycloud.cc')
16
+ })
17
+ ]
18
+ }
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
3
+ const path = require('path')
4
+ const merge = require('webpack-merge')
5
+ const vars = require('./webpack.vars')
6
+
7
+ const cssConfig = vars => {
8
+ if (vars.mobile) {
9
+ return require('./webpack.config.inline-styles.js')(vars)
10
+ } else {
11
+ return require('./webpack.config.extract')(vars)
12
+ }
13
+ }
14
+
15
+ module.exports = (env = {}) => {
16
+ const { filename, production, addAnalyzer } = vars(env)
17
+ const mobile = env.target === 'mobile'
18
+ return merge(
19
+ require('./webpack.config.base.js'),
20
+ addAnalyzer ? require('./webpack.config.analyzer.js') : {},
21
+ require('./webpack.config.jsx.js'),
22
+ require(production ? './webpack.config.prod' : './webpack.config.dev'),
23
+ cssConfig({ filename, mobile, production }),
24
+ {
25
+ output: {
26
+ filename: filename('js', mobile ? 'mobile' : ''),
27
+ path: path.resolve(__dirname, '../dist')
28
+ }
29
+ }
30
+ )
31
+ }
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ module.exports = env => ({
4
+ production: env.production,
5
+ mobile: env.mobile,
6
+ addAnalyzer: env.analyzer,
7
+ filename: (ext, prefix) =>
8
+ `cozy-bar${prefix ? `.${prefix}` : ''}${
9
+ env.production ? '.min' : ''
10
+ }.${ext}`
11
+ })