@mediafly/js-ui 49.0.3 → 50.0.0-beta.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.
package/webpack.config.js CHANGED
@@ -1,11 +1,11 @@
1
1
  const fs = require('fs')
2
- const isCI = require('is-ci')
3
2
  const path = require('path')
3
+
4
4
  const webpack = require('webpack')
5
+ const { ProgressPlugin, ProvidePlugin } = webpack
5
6
 
6
- const { CleanWebpackPlugin } = require('clean-webpack-plugin')
7
7
  const CopyWebpackPlugin = require('copy-webpack-plugin')
8
- const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries')
8
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
9
9
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
10
10
  const HtmlWebpackPlugin = require('html-webpack-plugin')
11
11
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
@@ -15,71 +15,39 @@ const WebpackConcatPlugin = require('webpack-concat-files-plugin')
15
15
  const WriteFilePlugin = require('write-file-webpack-plugin')
16
16
 
17
17
 
18
- module.exports = (options = {}) => {
19
-
20
- const isProd = (process.env.NODE_ENV === 'production')
18
+ module.exports = function (env) {
21
19
 
22
- const plugins = [
23
- new CleanWebpackPlugin(),
24
- new CopyWebpackPlugin({
25
- patterns: [
26
- { from: 'src/fonts', to: 'fonts' },
27
- { from: 'src/img', to: 'img' },
28
- ],
29
- }),
30
- new webpack.EnvironmentPlugin(options),
31
- new FixStyleOnlyEntriesPlugin({ silent: true, ignore: 'webpack-dev-server' }),
32
- new ForkTsCheckerWebpackPlugin({
33
- async: false,
34
- }),
35
- new HtmlWebpackPlugin({
36
- excludeChunks: ['components', 'standalone'],
37
- template: 'src/index.html',
38
- ...process.env
39
- }),
40
- new MiniCssExtractPlugin({
41
- filename: '[name].css',
42
- chunkFilename: '[id].css',
43
- }),
44
- // This plugin is used to generated the consumable css-module file by simply concat'ing the component modules.
45
- // We don't process them because the consumers will do so when importing styles from this file.
46
- new WebpackConcatPlugin({
47
- bundles: [{
48
- src: './src/components/less/**/*.module.css',
49
- dest: './dist/jsui.module.css',
50
- }],
51
- }),
52
- new webpack.ProvidePlugin({
53
- 'window.jQuery': 'jquery',
54
- }),
55
- new StylelintWebpackPlugin({
56
- files: [
57
- 'src/**/*.css',
58
- 'src/**/*.less',
59
- ],
60
- }),
61
- new WriteFilePlugin(),
62
- ]
63
-
64
- if (!isCI) {
65
- plugins.push(new webpack.ProgressPlugin({
66
- activeModules: false,
67
- }))
68
- }
20
+ // Get access to the "real" environment variable so we can tell if we're in CI.
21
+ // Expose this on Webpack's `env` for consistency in case we want to use it in code.
22
+ // (Webpack doesn't expose real env vars on its environment object here)
23
+ env.CI = !!process.env.CI
69
24
 
70
25
  return {
71
26
  devServer: {
72
- contentBase: path.resolve(process.cwd(), './dist'),
73
- disableHostCheck: true,
74
- host: 'local.imediafly.com',
75
- https: {
76
- cert: fs.readFileSync(path.join(__dirname, 'node_modules/@mediafly/frontend-certs/certs/localhost.crt')),
77
- key: fs.readFileSync(path.join(__dirname, 'node_modules/@mediafly/frontend-certs/certs/localhost.key')),
27
+ allowedHosts: [
28
+ 'imediafly.com',
29
+ 'mediafly.com',
30
+ ],
31
+ devMiddleware: {
32
+ publicPath: '/',
33
+ },
34
+ headers: {
35
+ 'Access-Control-Allow-Origin': '*',
36
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
37
+ 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
38
+ },
39
+ host: env.unitTests ? 'localhost' : 'local.imediafly.com',
40
+ hot: false,
41
+ server: {
42
+ type: 'https',
43
+ options: env.WEBPACK_SERVE && {
44
+ cert: fs.readFileSync(path.join(__dirname, '.certs/localhost.crt')),
45
+ key: fs.readFileSync(path.join(__dirname, '.certs/localhost.key')),
46
+ },
78
47
  },
79
48
  port: 8187,
80
- stats: 'minimal',
81
49
  },
82
- devtool: (isCI || isProd) ? false : '#eval-cheap-module-source-map',
50
+ devtool: env.CI ? false : 'cheap-module-source-map',
83
51
  entry: {
84
52
  bundle: './src/index.js',
85
53
  components: './src/components/index.ts',
@@ -87,121 +55,165 @@ module.exports = (options = {}) => {
87
55
  styles: './src/index.less',
88
56
  standalone: './src/components/less/standalone.less',
89
57
  },
90
- mode: isProd ? 'production' : 'development',
58
+ mode: 'development',
91
59
  module: {
92
- rules: [{
93
- test: /\.html$/,
94
- use: [
95
- {
96
- loader: 'raw-loader',
97
- options: {
98
- esModule: false, // This is necessary when updating from create-app's raw-loader v0.X...!
99
- }
100
- }
101
- ],
102
- exclude: [
103
- path.resolve(process.cwd(), 'src/index.html')
104
- ]
105
- }, {
106
- test: /\.ts$/,
107
- enforce: 'pre', // preload the tslint loader
108
- exclude: /node_modules/,
109
- use: ['tslint-loader']
110
- }, {
111
- test: /\.less|\.css$/,
112
- enforce: 'pre',
113
- loader: [
114
- 'import-glob-loader'
115
- ]
116
- }, {
117
- test: /\.less|\.css$/,
118
- use: [
119
- MiniCssExtractPlugin.loader,
120
- {
121
- loader: 'css-loader',
122
- options: {
123
- modules: {
124
- auto: true,
125
- getLocalIdent: (context, localIdentName, localName, options) => { // generate our own classnames, avoiding "-module" in the generated name
126
- const filename = context.resourcePath.replace(context.context, '')
127
- const component = filename.slice(1, filename.indexOf('.')) // remove leading slash and extension
128
- return `jsui-${component}__${localName}`
60
+ rules: [
61
+ {
62
+ test: /\.html$/,
63
+ type: 'asset/source',
64
+ exclude: [
65
+ path.resolve(process.cwd(), 'src/index.html'),
66
+ ],
67
+ }, {
68
+ test: /\.ts$/,
69
+ enforce: 'pre', // preload the tslint loader
70
+ exclude: /node_modules/,
71
+ loader: 'tslint-loader',
72
+ options: {
73
+ emitErrors: env.CI,
74
+ },
75
+ }, {
76
+ test: /\.less|\.css$/,
77
+ enforce: 'pre',
78
+ loader: 'import-glob-loader',
79
+ }, {
80
+ test: /\.less|\.css$/,
81
+ use: [
82
+ MiniCssExtractPlugin.loader,
83
+ {
84
+ loader: 'css-loader',
85
+ options: {
86
+ modules: {
87
+ auto: true,
88
+ getLocalIdent: (context, localIdentName, localName, options) => { // generate our own classnames, avoiding "-module" in the generated name
89
+ const filename = context.resourcePath.replace(context.context, '')
90
+ const component = filename.slice(1, filename.indexOf('.')) // remove leading slash and extension
91
+ return `jsui-${component}__${localName}`
92
+ },
93
+ },
94
+ url: {
95
+ filter: (url) => !url.startsWith('/'), // don't try to process absolute paths (e.g, fonts)
129
96
  },
130
97
  },
131
- url: (url) => !url.startsWith('/'), // don't try to process absolute paths (e.g, fonts)
132
- }
133
- },
134
- {
135
- loader: 'postcss-loader',
136
- options: {
137
- plugins: () => [
138
- require('autoprefixer')({
139
- grid: true,
140
- overrideBrowsersList: require('./browserslist.config.js'),
141
- }),
142
- require('postcss-modules-values'),
143
- ]
144
- }
145
- },
146
- {
147
- loader: 'less-loader',
148
- options: {
149
- lessOptions: {
150
- paths: [
151
- path.resolve(process.cwd(), 'src')
152
- ],
98
+ },
99
+ {
100
+ loader: 'postcss-loader',
101
+ options: {
102
+ postcssOptions: {
103
+ plugins: () => [
104
+ require('postcss-modules-values'),
105
+ require('postcss-nested'),
106
+ ],
107
+ },
108
+ },
109
+ },
110
+ {
111
+ loader: 'less-loader',
112
+ options: {
113
+ lessOptions: {
114
+ paths: [
115
+ path.resolve(process.cwd(), 'src')
116
+ ],
117
+ },
153
118
  },
154
- }
155
- }
156
- ]
157
- }, {
158
- test: /\.js$/,
159
- include: /(src)/,
160
- use: [
161
- {
162
- loader: 'babel-loader',
163
- options: {
164
- presets: [require('babel-preset-env')],
165
- plugins: [require('babel-plugin-angularjs-annotate')]
166
- }
167
- }
168
- ]
169
- }, {
170
- test: /\.(ts|tsx)$/,
171
- include: /(src)/,
172
- use: [
173
- {
174
- loader: 'babel-loader',
175
- options: {
176
- plugins: [require('babel-plugin-angularjs-annotate')]
177
- }
178
- }, {
179
- loader: 'ts-loader',
180
- options: {
181
- context: path.resolve(process.cwd()),
182
- configFile: 'tsconfig.json',
183
- logLevel: options.verbose ? 'info' : 'warn',
184
- onlyCompileBundledFiles: true,
185
- // transpileOnly: true
186
- }
187
- }
188
- ]
189
- }, {
190
- test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
191
- loader: 'file-loader'
192
- }]
119
+ },
120
+ ],
121
+ }, {
122
+ test: /\.js$/,
123
+ include: /(src)/,
124
+ use: [
125
+ {
126
+ loader: 'babel-loader',
127
+ options: {
128
+ presets: [require('babel-preset-env')],
129
+ plugins: [require('babel-plugin-angularjs-annotate')]
130
+ },
131
+ },
132
+ ],
133
+ }, {
134
+ test: /\.(ts)$/,
135
+ include: /(src)/,
136
+ use: [
137
+ {
138
+ loader: 'babel-loader',
139
+ options: {
140
+ plugins: [require('babel-plugin-angularjs-annotate')]
141
+ }
142
+ }, {
143
+ loader: 'ts-loader',
144
+ options: {
145
+ context: path.resolve(process.cwd()),
146
+ configFile: 'tsconfig.json',
147
+ onlyCompileBundledFiles: true,
148
+ // transpileOnly: true
149
+ },
150
+ },
151
+ ],
152
+ }, {
153
+ test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
154
+ loader: 'file-loader',
155
+ },
156
+ ],
157
+ },
158
+ optimization: {
159
+ minimizer: [
160
+ `...`, // TerserWebpackPlugin: https://webpack.js.org/plugins/terser-webpack-plugin/
161
+ new CssMinimizerPlugin({}),
162
+ ],
163
+ splitChunks: {
164
+ chunks: 'all',
165
+ },
193
166
  },
194
167
  output: {
168
+ clean: true,
195
169
  path: path.resolve(process.cwd(), 'dist'),
196
- pathinfo: false, // this is supposedly a perf improvement: https://webpack.js.org/guides/build-performance/#output-without-path-info
197
- filename: '[name].js'
170
+ filename: '[name].js',
198
171
  },
199
- performance: {
200
- hints: false,
201
- },
202
- plugins,
172
+ plugins: [
173
+ new CopyWebpackPlugin({
174
+ patterns: [
175
+ { from: 'src/fonts', to: 'fonts' },
176
+ { from: 'src/img', to: 'img' },
177
+ ],
178
+ }),
179
+ // new webpack.EnvironmentPlugin(options),
180
+ // new FixStyleOnlyEntriesPlugin({ silent: true, ignore: 'webpack-dev-server' }),
181
+ new ForkTsCheckerWebpackPlugin({
182
+ async: false,
183
+ }),
184
+ new HtmlWebpackPlugin({
185
+ excludeChunks: ['components', 'standalone'],
186
+ template: 'src/index.html',
187
+ ...process.env,
188
+ }),
189
+ new MiniCssExtractPlugin({
190
+ filename: '[name].css',
191
+ chunkFilename: '[id].css',
192
+ }),
193
+ // This plugin is used to generated the consumable css-module file by simply concat'ing the component modules.
194
+ // We don't process them because the consumers will do so when importing styles from this file.
195
+ new WebpackConcatPlugin({
196
+ bundles: [{
197
+ src: './src/components/less/**/*.module.css',
198
+ dest: './dist/jsui.module.css',
199
+ }],
200
+ }),
201
+ new ProvidePlugin({
202
+ 'window.jQuery': 'jquery',
203
+ }),
204
+ new StylelintWebpackPlugin({
205
+ files: [
206
+ 'src/**/*.css',
207
+ 'src/**/*.less',
208
+ ],
209
+ }),
210
+ new WriteFilePlugin(),
211
+ ...(!env.CI)
212
+ ? [new ProgressPlugin({ profile: false })]
213
+ : []
214
+ ],
203
215
  resolve: {
204
- extensions: ['.js', '.ts', '.tsx', '*'],
216
+ extensions: ['.js', '.ts', '*'],
205
217
  plugins: [
206
218
  new TsConfigPathsPlugin(),
207
219
  ],
package/cypress.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "baseUrl": "https://local.imediafly.com:8187",
3
- "reporter": "junit",
4
- "reporterOptions": {
5
- "mochaFile": "xmloutput/cypress-results.[hash].xml"
6
- },
7
- "testFiles": "**/*.spec.ts",
8
- "video": false,
9
- "viewportHeight": 1200
10
- }