@ovh-ux/manager-webpack-config 4.0.1 → 4.0.5
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/CHANGELOG.md +36 -0
- package/README.md +1 -1
- package/package.json +8 -26
- package/src/index.js +17 -0
- package/src/loaders/translation-inject.js +38 -0
- package/src/loaders/translation-json.js +7 -0
- package/src/loaders/translation-ui-router.js +40 -0
- package/src/webpack.common.js +280 -0
- package/src/webpack.prod.js +3 -0
- package/dist/index.js +0 -20
- package/dist/loaders/translation-inject.js +0 -37
- package/dist/loaders/translation-json.js +0 -5
- package/dist/loaders/translation-ui-router.js +0 -37
- package/dist/webpack.common.js +0 -230
- package/dist/webpack.prod.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## [4.0.5](https://github.com/ovh/manager/compare/@ovh-ux/manager-webpack-config@4.0.4...@ovh-ux/manager-webpack-config@4.0.5) (2021-11-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** upgrade some dependencies ([8463f75](https://github.com/ovh/manager/commit/8463f7587c2246a18b963d46351131d030600ae0))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [4.0.4](https://github.com/ovh/manager/compare/@ovh-ux/manager-webpack-config@4.0.3...@ovh-ux/manager-webpack-config@4.0.4) (2021-10-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **dev-deps:** update `@ovh-ux/component-rollup-config` to `^11.0.0` ([7cbdd08](https://github.com/ovh/manager/commit/7cbdd08ffaf8d7d05f0165bdf0d30d19ed9e428f))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [4.0.3](https://github.com/ovh/manager/compare/@ovh-ux/manager-webpack-config@4.0.2...@ovh-ux/manager-webpack-config@4.0.3) (2021-06-29)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **deps:** upgrade `@ovh-ux/component-rollup-config` to `v10.0.0` ([8eac31f](https://github.com/ovh/manager/commit/8eac31f81e46d1570c131cf55788d6435842ab6d))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [4.0.2](https://github.com/ovh/manager/compare/@ovh-ux/manager-webpack-config@4.0.1...@ovh-ux/manager-webpack-config@4.0.2) (2021-06-16)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Performance Improvements
|
|
32
|
+
|
|
33
|
+
* rename `*.ts` files into `*.js` ([036fdc9](https://github.com/ovh/manager/commit/036fdc985bf6f590e057ee2b32e6cf1a341f7bef))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
1
37
|
## [4.0.1](https://github.com/ovh/manager/compare/@ovh-ux/manager-webpack-config@4.0.0...@ovh-ux/manager-webpack-config@4.0.1) (2021-01-13)
|
|
2
38
|
|
|
3
39
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Extensible webpack configuration for the OVH Manager.
|
|
4
4
|
|
|
5
|
-
[](https://npmjs.com/package/@ovh-ux/manager-webpack-config) [](https://npmjs.com/package/@ovh-ux/manager-webpack-config?activeTab=dependencies) [](https://npmjs.com/package/@ovh-ux/manager-webpack-config?activeTab=dependencies)
|
|
5
|
+
[](https://npmjs.com/package/@ovh-ux/manager-webpack-config) [](https://npmjs.com/package/@ovh-ux/manager-webpack-config?activeTab=dependencies) [](https://npmjs.com/package/@ovh-ux/manager-webpack-config?activeTab=dependencies)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovh-ux/manager-webpack-config",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "OVHcloud manager shared webpack configuration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"configuration",
|
|
@@ -17,17 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "BSD-3-Clause",
|
|
19
19
|
"author": "OVH SAS",
|
|
20
|
-
"main": "
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsc",
|
|
26
|
-
"dev": "yarn run build",
|
|
27
|
-
"dev:watch": "tsc -w",
|
|
28
|
-
"lint": "eslint --quiet --fix src",
|
|
29
|
-
"prepare": "yarn run build"
|
|
30
|
-
},
|
|
20
|
+
"main": "./src/index.js",
|
|
31
21
|
"dependencies": {
|
|
32
22
|
"@babel/generator": "^7.10.3",
|
|
33
23
|
"@babel/parser": "^7.10.3",
|
|
@@ -36,8 +26,8 @@
|
|
|
36
26
|
"@babel/plugin-proposal-private-methods": "^7.10.1",
|
|
37
27
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
38
28
|
"@babel/preset-env": "^7.10.3",
|
|
39
|
-
"@ovh-ux/component-rollup-config": "^
|
|
40
|
-
"@ovh-ux/manager-webpack-dev-server": "^2.8.
|
|
29
|
+
"@ovh-ux/component-rollup-config": "^11.0.1",
|
|
30
|
+
"@ovh-ux/manager-webpack-dev-server": "^2.8.2",
|
|
41
31
|
"acorn": "^6.0.5",
|
|
42
32
|
"acorn-class-fields": "^0.3.7",
|
|
43
33
|
"acorn-dynamic-import": "^4.0.0",
|
|
@@ -58,15 +48,15 @@
|
|
|
58
48
|
"less-plugin-remcalc": "^0.1.0",
|
|
59
49
|
"loader-utils": "^2.0.0",
|
|
60
50
|
"lodash": "^4.17.15",
|
|
61
|
-
"mini-css-extract-plugin": "
|
|
62
|
-
"node-sass": "^
|
|
51
|
+
"mini-css-extract-plugin": "~1.2.1",
|
|
52
|
+
"node-sass": "^6.0.1",
|
|
63
53
|
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
|
64
54
|
"raw-loader": "^4.0.2",
|
|
65
55
|
"regenerator-runtime": "^0.13.7",
|
|
66
56
|
"resolve-url-loader": "^3.0.0",
|
|
67
|
-
"sass-loader": "^
|
|
57
|
+
"sass-loader": "^10.2.0",
|
|
68
58
|
"script-loader": "^0.7.2",
|
|
69
|
-
"style-loader": "^
|
|
59
|
+
"style-loader": "^2.0.0",
|
|
70
60
|
"terser-webpack-plugin": "^4.2.2",
|
|
71
61
|
"url-loader": "^4.1.1",
|
|
72
62
|
"webpack": "^4.44.2",
|
|
@@ -75,13 +65,5 @@
|
|
|
75
65
|
"webpack-merge": "^4.2.2",
|
|
76
66
|
"webpack-retry-chunk-load-plugin": "^1.4.0",
|
|
77
67
|
"webpackbar": "^4.0.0"
|
|
78
|
-
},
|
|
79
|
-
"devDependencies": {
|
|
80
|
-
"@typescript-eslint/eslint-plugin": "^2.11.0",
|
|
81
|
-
"@typescript-eslint/parser": "^2.11.0",
|
|
82
|
-
"eslint": "^6.7.2",
|
|
83
|
-
"eslint-config-airbnb-base": "^14.0.0",
|
|
84
|
-
"eslint-plugin-import": "^2.19.1",
|
|
85
|
-
"typescript": "^3.7.3"
|
|
86
68
|
}
|
|
87
69
|
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const merge = require('webpack-merge');
|
|
2
|
+
const devServer = require('@ovh-ux/manager-webpack-dev-server');
|
|
3
|
+
const common = require('./webpack.common');
|
|
4
|
+
const prodConfig = require('./webpack.prod');
|
|
5
|
+
|
|
6
|
+
module.exports = (opts, env) => {
|
|
7
|
+
const commonConfig = common(opts);
|
|
8
|
+
const devConfig = devServer.config(env);
|
|
9
|
+
const config = merge(commonConfig, env.production ? prodConfig : devConfig);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
commonConfig,
|
|
13
|
+
devConfig,
|
|
14
|
+
prodConfig,
|
|
15
|
+
config,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const loaderUtils = require('loader-utils');
|
|
2
|
+
const get = require('lodash/get');
|
|
3
|
+
const merge = require('lodash/merge');
|
|
4
|
+
const pick = require('lodash/pick');
|
|
5
|
+
const acorn = require('acorn');
|
|
6
|
+
const classFields = require('acorn-class-fields');
|
|
7
|
+
const optionalChaining = require('acorn-optional-chaining');
|
|
8
|
+
const privateMethods = require('acorn-private-methods');
|
|
9
|
+
const componentConfig = require('@ovh-ux/component-rollup-config');
|
|
10
|
+
const acornDynamicImport = require('acorn-dynamic-import');
|
|
11
|
+
|
|
12
|
+
const getOptions = Object.assign(loaderUtils.getOptions);
|
|
13
|
+
const dynamicImport = acornDynamicImport.default;
|
|
14
|
+
|
|
15
|
+
module.exports = function injectTranslationsLoader(source) {
|
|
16
|
+
const options = merge({ filtering: false }, getOptions(this));
|
|
17
|
+
const translationInject = get(componentConfig, 'plugins.translationInject');
|
|
18
|
+
|
|
19
|
+
const parser = acorn.Parser.extend(dynamicImport)
|
|
20
|
+
.extend(classFields)
|
|
21
|
+
.extend(optionalChaining)
|
|
22
|
+
.extend(privateMethods);
|
|
23
|
+
|
|
24
|
+
return get(
|
|
25
|
+
translationInject(
|
|
26
|
+
pick(options, ['subdirectory', 'filtering']),
|
|
27
|
+
).transform.bind({
|
|
28
|
+
parse: (code, opts = {}) =>
|
|
29
|
+
parser.parse(code, {
|
|
30
|
+
ecmaVersion: 9,
|
|
31
|
+
sourceType: 'module',
|
|
32
|
+
...opts,
|
|
33
|
+
}),
|
|
34
|
+
})(source, this.resourcePath),
|
|
35
|
+
'code',
|
|
36
|
+
source,
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const loaderUtils = require('loader-utils');
|
|
2
|
+
const get = require('lodash/get');
|
|
3
|
+
const merge = require('lodash/merge');
|
|
4
|
+
const pick = require('lodash/pick');
|
|
5
|
+
const acorn = require('acorn');
|
|
6
|
+
const classFields = require('acorn-class-fields');
|
|
7
|
+
const optionalChaining = require('acorn-optional-chaining');
|
|
8
|
+
const privateMethods = require('acorn-private-methods');
|
|
9
|
+
const componentConfig = require('@ovh-ux/component-rollup-config');
|
|
10
|
+
const acornDynamicImport = require('acorn-dynamic-import');
|
|
11
|
+
|
|
12
|
+
const getOptions = Object.assign(loaderUtils.getOptions);
|
|
13
|
+
const dynamicImport = acornDynamicImport.default;
|
|
14
|
+
|
|
15
|
+
module.exports = function translationUiRouterLoader(source) {
|
|
16
|
+
const options = merge({ filtering: false }, getOptions(this));
|
|
17
|
+
const translationUiRouter = get(
|
|
18
|
+
componentConfig,
|
|
19
|
+
'plugins.translationUiRouter',
|
|
20
|
+
);
|
|
21
|
+
const parser = acorn.Parser.extend(dynamicImport)
|
|
22
|
+
.extend(classFields)
|
|
23
|
+
.extend(optionalChaining)
|
|
24
|
+
.extend(privateMethods);
|
|
25
|
+
|
|
26
|
+
return get(
|
|
27
|
+
translationUiRouter(
|
|
28
|
+
pick(options, ['subdirectory', 'filtering']),
|
|
29
|
+
).transform.bind({
|
|
30
|
+
parse: (code, opts = {}) =>
|
|
31
|
+
parser.parse(code, {
|
|
32
|
+
ecmaVersion: 9,
|
|
33
|
+
sourceType: 'module',
|
|
34
|
+
...opts,
|
|
35
|
+
}),
|
|
36
|
+
})(source, this.resourcePath),
|
|
37
|
+
'code',
|
|
38
|
+
source,
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
3
|
+
const RemcalcPlugin = require('less-plugin-remcalc');
|
|
4
|
+
const WebpackBar = require('webpackbar');
|
|
5
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
6
|
+
const get = require('lodash/get');
|
|
7
|
+
const set = require('lodash/set');
|
|
8
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
9
|
+
const TerserJSPlugin = require('terser-webpack-plugin');
|
|
10
|
+
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
11
|
+
const webpackRetryChunckLoadPlugin = require('webpack-retry-chunk-load-plugin');
|
|
12
|
+
|
|
13
|
+
const RetryChunkLoadPlugin = Object.assign(
|
|
14
|
+
webpackRetryChunckLoadPlugin.RetryChunkLoadPlugin,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const webpack = require('webpack');
|
|
18
|
+
|
|
19
|
+
const cacheLoader = {
|
|
20
|
+
loader: 'cache-loader',
|
|
21
|
+
options: {
|
|
22
|
+
cacheDirectory: path.resolve(process.cwd(), 'node_modules/.cache-loader'),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// The common webpack configuration
|
|
27
|
+
|
|
28
|
+
module.exports = (opts) => {
|
|
29
|
+
const lessLoaderOptions = {
|
|
30
|
+
sourceMap: true,
|
|
31
|
+
plugins: [
|
|
32
|
+
RemcalcPlugin, // required by ovh-ui-kit
|
|
33
|
+
],
|
|
34
|
+
relativeUrls: false,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if ('lessPath' in opts) {
|
|
38
|
+
set(lessLoaderOptions, 'paths', opts.lessPath);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if ('lessJavascriptEnabled' in opts) {
|
|
42
|
+
set(lessLoaderOptions, 'javascriptEnabled', opts.lessJavascriptEnabled);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const jsExclude = [
|
|
46
|
+
/\/node_modules/, // vendors
|
|
47
|
+
/\/dist/, // bundled files
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
plugins: [
|
|
52
|
+
// copy application assets
|
|
53
|
+
// note: we could use the html-loader plugin but it wouldn't work for dynamic src attributes!
|
|
54
|
+
new CopyWebpackPlugin(
|
|
55
|
+
get(opts, 'assets.files', []),
|
|
56
|
+
get(opts, 'assets.options', {}),
|
|
57
|
+
),
|
|
58
|
+
|
|
59
|
+
// see : https://github.com/jantimon/html-webpack-plugin
|
|
60
|
+
new HtmlWebpackPlugin({
|
|
61
|
+
template: opts.template, // path to application's main html template
|
|
62
|
+
}),
|
|
63
|
+
|
|
64
|
+
// display pretty loading bars
|
|
65
|
+
new WebpackBar({
|
|
66
|
+
name: 'OVH Manager',
|
|
67
|
+
color: '#59d2ef',
|
|
68
|
+
}),
|
|
69
|
+
|
|
70
|
+
new MiniCssExtractPlugin({
|
|
71
|
+
filename: '[name].[contenthash].css',
|
|
72
|
+
chunkFilename: '[id].css',
|
|
73
|
+
}),
|
|
74
|
+
|
|
75
|
+
new webpack.DefinePlugin({
|
|
76
|
+
__VERSION__: process.env.VERSION ? `'${process.env.VERSION}'` : 'null',
|
|
77
|
+
}),
|
|
78
|
+
|
|
79
|
+
new RetryChunkLoadPlugin({
|
|
80
|
+
// optional stringified function to get the cache busting query string appended to the script src
|
|
81
|
+
// if not set will default to appending the string `?cache-bust=true`
|
|
82
|
+
cacheBust: `function() {
|
|
83
|
+
return Date.now();
|
|
84
|
+
}`,
|
|
85
|
+
// optional value to set the maximum number of retries to load the chunk. Default is 1
|
|
86
|
+
maxRetries: 5,
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
|
|
90
|
+
resolve: {
|
|
91
|
+
modules: ['./node_modules', path.resolve('./node_modules')],
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
resolveLoader: {
|
|
95
|
+
// webpack module resolution paths
|
|
96
|
+
modules: [
|
|
97
|
+
'./node_modules', // #1 check in module's relative node_module directory
|
|
98
|
+
path.resolve('./node_modules'), // #2 check in application's node_module directory
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
module: {
|
|
103
|
+
rules: [
|
|
104
|
+
// load HTML files as string (raw-loader)
|
|
105
|
+
{
|
|
106
|
+
test: /\.html$/,
|
|
107
|
+
loader: 'raw-loader',
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// load images & fonts into file or convert to base64 if size < 10Kib
|
|
111
|
+
{
|
|
112
|
+
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
|
|
113
|
+
loader: 'url-loader',
|
|
114
|
+
options: {
|
|
115
|
+
limit: 10000,
|
|
116
|
+
esModule: false,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
// load css files
|
|
121
|
+
{
|
|
122
|
+
test: /\.css$/,
|
|
123
|
+
use: [
|
|
124
|
+
MiniCssExtractPlugin.loader,
|
|
125
|
+
cacheLoader,
|
|
126
|
+
{
|
|
127
|
+
loader: 'css-loader', // translates CSS into CommonJS
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
loader: 'resolve-url-loader', // specify relative path for Less files
|
|
131
|
+
options: {
|
|
132
|
+
root: opts.root,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
// load Less files
|
|
139
|
+
{
|
|
140
|
+
test: /\.less$/,
|
|
141
|
+
use: [
|
|
142
|
+
MiniCssExtractPlugin.loader,
|
|
143
|
+
cacheLoader,
|
|
144
|
+
{
|
|
145
|
+
loader: 'css-loader', // translates CSS into CommonJS
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
loader: 'resolve-url-loader', // specify relative path for Less files
|
|
149
|
+
options: {
|
|
150
|
+
root: opts.root,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
loader: 'less-loader', // compiles Less to CSS
|
|
155
|
+
options: { lessOptions: lessLoaderOptions },
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
// load Sass files
|
|
161
|
+
{
|
|
162
|
+
test: /\.scss$/,
|
|
163
|
+
use: [
|
|
164
|
+
MiniCssExtractPlugin.loader,
|
|
165
|
+
cacheLoader,
|
|
166
|
+
'css-loader', // translates CSS into CommonJS
|
|
167
|
+
'sass-loader', // compiles Sass to CSS
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// normalize json translation files
|
|
172
|
+
{
|
|
173
|
+
test: /Messages_\w+_\w+\.json$/,
|
|
174
|
+
use: [
|
|
175
|
+
cacheLoader,
|
|
176
|
+
{
|
|
177
|
+
loader: path.resolve(__dirname, './loaders/translation-json.js'),
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
// load JS files
|
|
183
|
+
{
|
|
184
|
+
test: /\.js$/,
|
|
185
|
+
exclude: jsExclude,
|
|
186
|
+
use: [
|
|
187
|
+
cacheLoader,
|
|
188
|
+
{
|
|
189
|
+
loader: 'babel-loader', // babelify JS sources
|
|
190
|
+
options: {
|
|
191
|
+
presets: [
|
|
192
|
+
require.resolve('@babel/preset-env'), // babel preset configuration
|
|
193
|
+
],
|
|
194
|
+
plugins: [
|
|
195
|
+
require.resolve('@babel/plugin-proposal-class-properties'), // class properties
|
|
196
|
+
require.resolve('@babel/plugin-proposal-optional-chaining'), // optional chaining
|
|
197
|
+
require.resolve('@babel/plugin-proposal-private-methods'), // private methods
|
|
198
|
+
require.resolve('@babel/plugin-syntax-dynamic-import'), // dynamic es6 imports
|
|
199
|
+
require.resolve('babel-plugin-angularjs-annotate'), // ng annotate
|
|
200
|
+
],
|
|
201
|
+
shouldPrintComment: (val) => !/@ngInject/.test(val),
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// inject translation imports into JS source code,
|
|
208
|
+
// given proper ui-router state 'translations' property
|
|
209
|
+
{
|
|
210
|
+
test: /\.js$/,
|
|
211
|
+
exclude: jsExclude,
|
|
212
|
+
enforce: 'pre',
|
|
213
|
+
use: [
|
|
214
|
+
cacheLoader,
|
|
215
|
+
{
|
|
216
|
+
loader: path.resolve(
|
|
217
|
+
__dirname,
|
|
218
|
+
'./loaders/translation-ui-router.js',
|
|
219
|
+
),
|
|
220
|
+
options: {
|
|
221
|
+
subdirectory: 'translations',
|
|
222
|
+
filtering: false,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
// inject translation with @ngTranslationsInject comment
|
|
229
|
+
{
|
|
230
|
+
test: /\.js$/,
|
|
231
|
+
exclude: jsExclude,
|
|
232
|
+
enforce: 'pre',
|
|
233
|
+
use: [
|
|
234
|
+
cacheLoader,
|
|
235
|
+
{
|
|
236
|
+
loader: path.resolve(
|
|
237
|
+
__dirname,
|
|
238
|
+
'./loaders/translation-inject.js',
|
|
239
|
+
),
|
|
240
|
+
options: {
|
|
241
|
+
filtering: false,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
], // \rules
|
|
247
|
+
}, // \module
|
|
248
|
+
|
|
249
|
+
optimization: {
|
|
250
|
+
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
|
|
251
|
+
runtimeChunk: 'single',
|
|
252
|
+
// bundle spliting configuration
|
|
253
|
+
splitChunks: {
|
|
254
|
+
// vendors bundle containing node_modules source code
|
|
255
|
+
cacheGroups: {
|
|
256
|
+
bower: {
|
|
257
|
+
chunks: 'initial',
|
|
258
|
+
test: /[\\/]node_modules[\\/]@bower_components[\\/]/,
|
|
259
|
+
name: 'bower',
|
|
260
|
+
enforce: true,
|
|
261
|
+
priority: 1,
|
|
262
|
+
},
|
|
263
|
+
ovh: {
|
|
264
|
+
chunks: 'initial',
|
|
265
|
+
test: /[\\/]node_modules[\\/]@ovh-ux[\\/]/,
|
|
266
|
+
name: 'ovh',
|
|
267
|
+
enforce: true,
|
|
268
|
+
priority: 1,
|
|
269
|
+
},
|
|
270
|
+
vendor: {
|
|
271
|
+
chunks: 'initial',
|
|
272
|
+
test: /[\\/]node_modules[\\/]/,
|
|
273
|
+
name: 'vendor',
|
|
274
|
+
enforce: true,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
}, // \optimization
|
|
279
|
+
};
|
|
280
|
+
};
|
package/dist/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var webpack_merge_1 = __importDefault(require("webpack-merge"));
|
|
6
|
-
var manager_webpack_dev_server_1 = __importDefault(require("@ovh-ux/manager-webpack-dev-server"));
|
|
7
|
-
var webpack_common_1 = __importDefault(require("./webpack.common"));
|
|
8
|
-
var webpack_prod_1 = __importDefault(require("./webpack.prod"));
|
|
9
|
-
module.exports = function (opts, env) {
|
|
10
|
-
if (env === void 0) { env = {}; }
|
|
11
|
-
var commonConfig = webpack_common_1.default(opts);
|
|
12
|
-
var devConfig = manager_webpack_dev_server_1.default.config(env);
|
|
13
|
-
var config = webpack_merge_1.default(commonConfig, env.production ? webpack_prod_1.default : devConfig);
|
|
14
|
-
return {
|
|
15
|
-
commonConfig: commonConfig,
|
|
16
|
-
devConfig: devConfig,
|
|
17
|
-
prodConfig: webpack_prod_1.default,
|
|
18
|
-
config: config,
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
var lodash_1 = require("lodash");
|
|
17
|
-
var loader_utils_1 = require("loader-utils");
|
|
18
|
-
var acorn_1 = require("acorn");
|
|
19
|
-
var acorn_class_fields_1 = __importDefault(require("acorn-class-fields"));
|
|
20
|
-
var acorn_optional_chaining_1 = __importDefault(require("acorn-optional-chaining"));
|
|
21
|
-
var acorn_private_methods_1 = __importDefault(require("acorn-private-methods"));
|
|
22
|
-
var component_rollup_config_1 = __importDefault(require("@ovh-ux/component-rollup-config"));
|
|
23
|
-
var acorn_dynamic_import_1 = __importDefault(require("acorn-dynamic-import"));
|
|
24
|
-
module.exports = function injectTranslationsLoader(source) {
|
|
25
|
-
var options = lodash_1.merge({ filtering: false }, loader_utils_1.getOptions(this));
|
|
26
|
-
var translationInject = lodash_1.get(component_rollup_config_1.default, 'plugins.translationInject');
|
|
27
|
-
var parser = acorn_1.Parser.extend(acorn_dynamic_import_1.default)
|
|
28
|
-
.extend(acorn_class_fields_1.default)
|
|
29
|
-
.extend(acorn_optional_chaining_1.default)
|
|
30
|
-
.extend(acorn_private_methods_1.default);
|
|
31
|
-
return lodash_1.get(translationInject(lodash_1.pick(options, ['subdirectory', 'filtering'])).transform.bind({
|
|
32
|
-
parse: function (code, opts) {
|
|
33
|
-
if (opts === void 0) { opts = {}; }
|
|
34
|
-
return parser.parse(code, __assign({ ecmaVersion: 9, sourceType: 'module' }, opts));
|
|
35
|
-
},
|
|
36
|
-
})(source, this.resourcePath), 'code', source);
|
|
37
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
var lodash_1 = require("lodash");
|
|
17
|
-
var loader_utils_1 = require("loader-utils");
|
|
18
|
-
var acorn_1 = require("acorn");
|
|
19
|
-
var acorn_class_fields_1 = __importDefault(require("acorn-class-fields"));
|
|
20
|
-
var acorn_optional_chaining_1 = __importDefault(require("acorn-optional-chaining"));
|
|
21
|
-
var acorn_private_methods_1 = __importDefault(require("acorn-private-methods"));
|
|
22
|
-
var component_rollup_config_1 = __importDefault(require("@ovh-ux/component-rollup-config"));
|
|
23
|
-
var acorn_dynamic_import_1 = __importDefault(require("acorn-dynamic-import"));
|
|
24
|
-
module.exports = function translationUiRouterLoader(source) {
|
|
25
|
-
var options = lodash_1.merge({ filtering: false }, loader_utils_1.getOptions(this));
|
|
26
|
-
var translationUiRouter = lodash_1.get(component_rollup_config_1.default, 'plugins.translationUiRouter');
|
|
27
|
-
var parser = acorn_1.Parser.extend(acorn_dynamic_import_1.default)
|
|
28
|
-
.extend(acorn_class_fields_1.default)
|
|
29
|
-
.extend(acorn_optional_chaining_1.default)
|
|
30
|
-
.extend(acorn_private_methods_1.default);
|
|
31
|
-
return lodash_1.get(translationUiRouter(lodash_1.pick(options, ['subdirectory', 'filtering'])).transform.bind({
|
|
32
|
-
parse: function (code, opts) {
|
|
33
|
-
if (opts === void 0) { opts = {}; }
|
|
34
|
-
return parser.parse(code, __assign({ ecmaVersion: 9, sourceType: 'module' }, opts));
|
|
35
|
-
},
|
|
36
|
-
})(source, this.resourcePath), 'code', source);
|
|
37
|
-
};
|
package/dist/webpack.common.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
-
if (mod && mod.__esModule) return mod;
|
|
4
|
-
var result = {};
|
|
5
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
-
result["default"] = mod;
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
var path = __importStar(require("path"));
|
|
13
|
-
var html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
14
|
-
var less_plugin_remcalc_1 = __importDefault(require("less-plugin-remcalc"));
|
|
15
|
-
var webpackbar_1 = __importDefault(require("webpackbar"));
|
|
16
|
-
var copy_webpack_plugin_1 = __importDefault(require("copy-webpack-plugin"));
|
|
17
|
-
var get_1 = __importDefault(require("lodash/get"));
|
|
18
|
-
var set_1 = __importDefault(require("lodash/set"));
|
|
19
|
-
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
20
|
-
var terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
21
|
-
var optimize_css_assets_webpack_plugin_1 = __importDefault(require("optimize-css-assets-webpack-plugin"));
|
|
22
|
-
var webpack_retry_chunk_load_plugin_1 = require("webpack-retry-chunk-load-plugin");
|
|
23
|
-
var webpack = require('webpack');
|
|
24
|
-
var cacheLoader = {
|
|
25
|
-
loader: 'cache-loader',
|
|
26
|
-
options: {
|
|
27
|
-
cacheDirectory: path.resolve(process.cwd(), 'node_modules/.cache-loader'),
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
module.exports = function (opts) {
|
|
31
|
-
var lessLoaderOptions = {
|
|
32
|
-
sourceMap: true,
|
|
33
|
-
plugins: [
|
|
34
|
-
less_plugin_remcalc_1.default,
|
|
35
|
-
],
|
|
36
|
-
relativeUrls: false,
|
|
37
|
-
};
|
|
38
|
-
if ('lessPath' in opts) {
|
|
39
|
-
set_1.default(lessLoaderOptions, 'paths', opts.lessPath);
|
|
40
|
-
}
|
|
41
|
-
if ('lessJavascriptEnabled' in opts) {
|
|
42
|
-
set_1.default(lessLoaderOptions, 'javascriptEnabled', opts.lessJavascriptEnabled);
|
|
43
|
-
}
|
|
44
|
-
var jsExclude = [
|
|
45
|
-
/\/node_modules/,
|
|
46
|
-
/\/dist/,
|
|
47
|
-
];
|
|
48
|
-
return {
|
|
49
|
-
plugins: [
|
|
50
|
-
new copy_webpack_plugin_1.default(get_1.default(opts, 'assets.files', []), get_1.default(opts, 'assets.options', {})),
|
|
51
|
-
new html_webpack_plugin_1.default({
|
|
52
|
-
template: opts.template,
|
|
53
|
-
}),
|
|
54
|
-
new webpackbar_1.default({
|
|
55
|
-
name: 'OVH Manager',
|
|
56
|
-
color: '#59d2ef',
|
|
57
|
-
}),
|
|
58
|
-
new mini_css_extract_plugin_1.default({
|
|
59
|
-
filename: '[name].[contenthash].css',
|
|
60
|
-
chunkFilename: '[id].css',
|
|
61
|
-
}),
|
|
62
|
-
new webpack.DefinePlugin({
|
|
63
|
-
__VERSION__: process.env.VERSION ? "'" + process.env.VERSION + "'" : 'null',
|
|
64
|
-
}),
|
|
65
|
-
new webpack_retry_chunk_load_plugin_1.RetryChunkLoadPlugin({
|
|
66
|
-
cacheBust: "function() {\n return Date.now();\n }",
|
|
67
|
-
maxRetries: 5,
|
|
68
|
-
}),
|
|
69
|
-
],
|
|
70
|
-
resolve: {
|
|
71
|
-
modules: ['./node_modules', path.resolve('./node_modules')],
|
|
72
|
-
},
|
|
73
|
-
resolveLoader: {
|
|
74
|
-
modules: [
|
|
75
|
-
'./node_modules',
|
|
76
|
-
path.resolve('./node_modules'),
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
module: {
|
|
80
|
-
rules: [
|
|
81
|
-
{
|
|
82
|
-
test: /\.html$/,
|
|
83
|
-
loader: 'raw-loader',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
|
|
87
|
-
loader: 'url-loader',
|
|
88
|
-
options: {
|
|
89
|
-
limit: 10000,
|
|
90
|
-
esModule: false,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
test: /\.css$/,
|
|
95
|
-
use: [
|
|
96
|
-
mini_css_extract_plugin_1.default.loader,
|
|
97
|
-
cacheLoader,
|
|
98
|
-
{
|
|
99
|
-
loader: 'css-loader',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
loader: 'resolve-url-loader',
|
|
103
|
-
options: {
|
|
104
|
-
root: opts.root,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
test: /\.less$/,
|
|
111
|
-
use: [
|
|
112
|
-
mini_css_extract_plugin_1.default.loader,
|
|
113
|
-
cacheLoader,
|
|
114
|
-
{
|
|
115
|
-
loader: 'css-loader',
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
loader: 'resolve-url-loader',
|
|
119
|
-
options: {
|
|
120
|
-
root: opts.root,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
loader: 'less-loader',
|
|
125
|
-
options: { lessOptions: lessLoaderOptions },
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
test: /\.scss$/,
|
|
131
|
-
use: [
|
|
132
|
-
mini_css_extract_plugin_1.default.loader,
|
|
133
|
-
cacheLoader,
|
|
134
|
-
'css-loader',
|
|
135
|
-
'sass-loader',
|
|
136
|
-
],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
test: /Messages_\w+_\w+\.json$/,
|
|
140
|
-
use: [
|
|
141
|
-
cacheLoader,
|
|
142
|
-
{
|
|
143
|
-
loader: path.resolve(__dirname, './loaders/translation-json.js'),
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
test: /\.js$/,
|
|
149
|
-
exclude: jsExclude,
|
|
150
|
-
use: [
|
|
151
|
-
cacheLoader,
|
|
152
|
-
{
|
|
153
|
-
loader: 'babel-loader',
|
|
154
|
-
options: {
|
|
155
|
-
presets: [
|
|
156
|
-
require.resolve('@babel/preset-env'),
|
|
157
|
-
],
|
|
158
|
-
plugins: [
|
|
159
|
-
require.resolve('@babel/plugin-proposal-class-properties'),
|
|
160
|
-
require.resolve('@babel/plugin-proposal-optional-chaining'),
|
|
161
|
-
require.resolve('@babel/plugin-proposal-private-methods'),
|
|
162
|
-
require.resolve('@babel/plugin-syntax-dynamic-import'),
|
|
163
|
-
require.resolve('babel-plugin-angularjs-annotate'),
|
|
164
|
-
],
|
|
165
|
-
shouldPrintComment: function (val) { return !/@ngInject/.test(val); },
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
test: /\.js$/,
|
|
172
|
-
exclude: jsExclude,
|
|
173
|
-
enforce: 'pre',
|
|
174
|
-
use: [
|
|
175
|
-
cacheLoader,
|
|
176
|
-
{
|
|
177
|
-
loader: path.resolve(__dirname, './loaders/translation-ui-router.js'),
|
|
178
|
-
options: {
|
|
179
|
-
subdirectory: 'translations',
|
|
180
|
-
filtering: false,
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
test: /\.js$/,
|
|
187
|
-
exclude: jsExclude,
|
|
188
|
-
enforce: 'pre',
|
|
189
|
-
use: [
|
|
190
|
-
cacheLoader,
|
|
191
|
-
{
|
|
192
|
-
loader: path.resolve(__dirname, './loaders/translation-inject.js'),
|
|
193
|
-
options: {
|
|
194
|
-
filtering: false,
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
},
|
|
201
|
-
optimization: {
|
|
202
|
-
minimizer: [new terser_webpack_plugin_1.default({}), new optimize_css_assets_webpack_plugin_1.default({})],
|
|
203
|
-
runtimeChunk: 'single',
|
|
204
|
-
splitChunks: {
|
|
205
|
-
cacheGroups: {
|
|
206
|
-
bower: {
|
|
207
|
-
chunks: 'initial',
|
|
208
|
-
test: /[\\/]node_modules[\\/]@bower_components[\\/]/,
|
|
209
|
-
name: 'bower',
|
|
210
|
-
enforce: true,
|
|
211
|
-
priority: 1,
|
|
212
|
-
},
|
|
213
|
-
ovh: {
|
|
214
|
-
chunks: 'initial',
|
|
215
|
-
test: /[\\/]node_modules[\\/]@ovh-ux[\\/]/,
|
|
216
|
-
name: 'ovh',
|
|
217
|
-
enforce: true,
|
|
218
|
-
priority: 1,
|
|
219
|
-
},
|
|
220
|
-
vendor: {
|
|
221
|
-
chunks: 'initial',
|
|
222
|
-
test: /[\\/]node_modules[\\/]/,
|
|
223
|
-
name: 'vendor',
|
|
224
|
-
enforce: true,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
};
|
package/dist/webpack.prod.js
DELETED