@lipemat/js-boilerplate 9.4.3 → 9.4.4
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/config/webpack.dev.js +3 -3
- package/config/webpack.dist.js +31 -25
- package/helpers/config.js +28 -0
- package/package.json +1 -1
package/config/webpack.dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {getConfig,
|
|
1
|
+
const {getConfig, getTsConfigFile} = require( '../helpers/config' );
|
|
2
2
|
const webpack = require( 'webpack' );
|
|
3
3
|
const path = require( 'path' );
|
|
4
4
|
const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );
|
|
@@ -22,12 +22,12 @@ const plugins = [
|
|
|
22
22
|
|
|
23
23
|
// Loads a thread, which verifies any TypeScripts on changes.
|
|
24
24
|
// Only use this if the project has a tsconfig.json file.
|
|
25
|
-
if (
|
|
25
|
+
if ( '' !== getTsConfigFile() ) {
|
|
26
26
|
plugins.push( new ForkTsCheckerWebpackPlugin( {
|
|
27
27
|
devServer: false,
|
|
28
28
|
formatter: 'basic',
|
|
29
29
|
typescript: {
|
|
30
|
-
configFile:
|
|
30
|
+
configFile: getTsConfigFile(),
|
|
31
31
|
},
|
|
32
32
|
} ) );
|
|
33
33
|
}
|
package/config/webpack.dist.js
CHANGED
|
@@ -22,6 +22,36 @@ const ManifestPlugin = new WebpackAssetsManifest( {
|
|
|
22
22
|
output: 'manifest.json',
|
|
23
23
|
} );
|
|
24
24
|
|
|
25
|
+
const plugins = [
|
|
26
|
+
new webpack.ProvidePlugin( {
|
|
27
|
+
jQuery: 'jquery',
|
|
28
|
+
$: 'jquery',
|
|
29
|
+
} ),
|
|
30
|
+
new MiniCssExtractPlugin( {
|
|
31
|
+
filename: '[name].css',
|
|
32
|
+
chunkFilename: '[name].[contenthash].css',
|
|
33
|
+
} ),
|
|
34
|
+
new CleanWebpackPlugin( {
|
|
35
|
+
// Remove all files except the `.running` file created by "Start".
|
|
36
|
+
cleanOnceBeforeBuildPatterns: [ '**/*', '!.running' ],
|
|
37
|
+
} ),
|
|
38
|
+
new SubresourceIntegrityPlugin( {
|
|
39
|
+
hashFuncNames: [ 'sha384' ],
|
|
40
|
+
} ),
|
|
41
|
+
new WebpackAssetsHash( ManifestPlugin ),
|
|
42
|
+
ManifestPlugin,
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
if ( '' !== getTsConfigFile() ) {
|
|
46
|
+
plugins.push( new ForkTsCheckerWebpackPlugin( {
|
|
47
|
+
formatter: 'basic',
|
|
48
|
+
typescript: {
|
|
49
|
+
configFile: getTsConfigFile(),
|
|
50
|
+
},
|
|
51
|
+
} ) );
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
25
55
|
module.exports = {
|
|
26
56
|
devtool: false,
|
|
27
57
|
entry: getEntries(),
|
|
@@ -69,31 +99,7 @@ module.exports = {
|
|
|
69
99
|
'node_modules',
|
|
70
100
|
],
|
|
71
101
|
},
|
|
72
|
-
plugins
|
|
73
|
-
new webpack.ProvidePlugin( {
|
|
74
|
-
jQuery: 'jquery',
|
|
75
|
-
$: 'jquery',
|
|
76
|
-
} ),
|
|
77
|
-
new MiniCssExtractPlugin( {
|
|
78
|
-
filename: '[name].css',
|
|
79
|
-
chunkFilename: '[name].[contenthash].css',
|
|
80
|
-
} ),
|
|
81
|
-
new CleanWebpackPlugin( {
|
|
82
|
-
// Remove all files except the `.running` file created by "Start".
|
|
83
|
-
cleanOnceBeforeBuildPatterns: [ '**/*', '!.running' ],
|
|
84
|
-
} ),
|
|
85
|
-
new ForkTsCheckerWebpackPlugin( {
|
|
86
|
-
formatter: 'basic',
|
|
87
|
-
typescript: {
|
|
88
|
-
configFile: config.workingDirectory + '/tsconfig.json',
|
|
89
|
-
},
|
|
90
|
-
} ),
|
|
91
|
-
new SubresourceIntegrityPlugin( {
|
|
92
|
-
hashFuncNames: [ 'sha384' ],
|
|
93
|
-
} ),
|
|
94
|
-
new WebpackAssetsHash( ManifestPlugin ),
|
|
95
|
-
ManifestPlugin,
|
|
96
|
-
],
|
|
102
|
+
plugins,
|
|
97
103
|
module: {
|
|
98
104
|
rules: [
|
|
99
105
|
{
|
package/helpers/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const packageConfig = require( './package-config' );
|
|
2
2
|
const path = require( 'path' );
|
|
3
|
+
const fs = require( 'fs' );
|
|
3
4
|
const once = require( 'lodash/once' );
|
|
4
5
|
const browserslist = require( 'browserslist' );
|
|
5
6
|
|
|
@@ -104,6 +105,32 @@ function getExtensionsConfig( fileName, defaultConfig ) {
|
|
|
104
105
|
return config;
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Get the path to the "tsconfig.json" file if it exists.
|
|
110
|
+
*
|
|
111
|
+
* 1. The working directory.
|
|
112
|
+
* 2. The package directory.
|
|
113
|
+
*
|
|
114
|
+
* The package directory takes priority over the working directory.
|
|
115
|
+
*
|
|
116
|
+
*
|
|
117
|
+
* @return {string}
|
|
118
|
+
*/
|
|
119
|
+
function getTsConfigFile() {
|
|
120
|
+
const possibles = [
|
|
121
|
+
// Backward compatible for before @lipemat/eslint-config version 3.
|
|
122
|
+
path.resolve( packageConfig.workingDirectory + '/tsconfig.json' ),
|
|
123
|
+
path.resolve( packageConfig.packageDirectory + '/tsconfig.json' ),
|
|
124
|
+
];
|
|
125
|
+
let tsConfig = '';
|
|
126
|
+
possibles.forEach( filePath => {
|
|
127
|
+
if ( fs.existsSync( filePath ) ) {
|
|
128
|
+
tsConfig = filePath;
|
|
129
|
+
}
|
|
130
|
+
} );
|
|
131
|
+
return tsConfig;
|
|
132
|
+
}
|
|
133
|
+
|
|
107
134
|
/**
|
|
108
135
|
* If browserslist is not specified, we fall back to WordPress defaults
|
|
109
136
|
* except for > 1% we don't support by default.
|
|
@@ -135,4 +162,5 @@ module.exports = {
|
|
|
135
162
|
getDefaultBrowsersList,
|
|
136
163
|
getExtensionsConfig,
|
|
137
164
|
hasLocalOverride,
|
|
165
|
+
getTsConfigFile,
|
|
138
166
|
};
|