@emulsify/core 1.2.1 → 1.3.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/.history/config/webpack/loaders_20240730152304.js +87 -0
- package/.history/config/webpack/loaders_20240730152315.js +87 -0
- package/.history/config/webpack/{loaders_20240401184511.js → loaders_20240806083911.js} +3 -2
- package/.history/config/webpack/loaders_20240806084032.js +88 -0
- package/.history/config/webpack/plugins_20240730152746.js +77 -0
- package/.history/config/webpack/plugins_20240730152818.js +76 -0
- package/.history/config/webpack/plugins_20240730153144.js +76 -0
- package/.history/config/webpack/plugins_20240730153215.js +76 -0
- package/.history/config/webpack/{webpack.common_20240607090919.js → webpack.common_20240730152548.js} +5 -3
- package/.history/config/webpack/webpack.common_20240730152652.js +76 -0
- package/.history/package_20240730153116.json +136 -0
- package/.history/package_20240806081212.json +135 -0
- package/.history/package_20240806081229.json +135 -0
- package/.history/package_20240806081258.json +135 -0
- package/.history/package_20240806081538.json +135 -0
- package/.history/package_20240806082035.json +135 -0
- package/.history/package_20240806082121.json +135 -0
- package/.history/package_20240806082142.json +135 -0
- package/.history/package_20240806082313.json +135 -0
- package/.history/package_20240806082418.json +135 -0
- package/.history/package_20240806083920.json +135 -0
- package/config/webpack/loaders.js +1 -0
- package/package.json +10 -10
- package/.history/config/webpack/plugins_20240401184104.js +0 -48
- /package/.history/config/webpack/{loaders_20240610084138.js → loaders_20240731075844.js} +0 -0
- /package/.history/config/webpack/{plugins_20240607163148.js → plugins_20240731075839.js} +0 -0
- /package/.history/config/webpack/{webpack.common_20240607163224.js → webpack.common_20240731075910.js} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
2
|
+
const globImporter = require('node-sass-glob-importer');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
|
|
5
|
+
let babelConfig;
|
|
6
|
+
let postcssConfig;
|
|
7
|
+
|
|
8
|
+
// Check if custom babel config is available.
|
|
9
|
+
if (fs.existsSync('./config/babel.config.js')) {
|
|
10
|
+
babelConfig = './config/babel.config.js';
|
|
11
|
+
} else {
|
|
12
|
+
babelConfig = './node_modules/@emulsify/core/config/babel.config.js';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Check if custom postcss config is available.
|
|
16
|
+
if (fs.existsSync('./config/postcss.config.js')) {
|
|
17
|
+
postcssConfig = './config/postcss.config.js';
|
|
18
|
+
} else {
|
|
19
|
+
postcssConfig = './node_modules/@emulsify/core/config/postcss.config.js';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const JSLoader = {
|
|
23
|
+
test: /^(?!.*\.(stories|component)\.js$).*\.js$/,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
loader: 'babel-loader',
|
|
26
|
+
options: {
|
|
27
|
+
configFile: babelConfig,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ImageLoader = {
|
|
32
|
+
test: /\.(jpe?g|png|gif)$/i,
|
|
33
|
+
exclude: /icons\/.*\.svg$/,
|
|
34
|
+
loader: 'file-loader',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const CSSLoader = {
|
|
38
|
+
test: /\.s[ac]ss$/i,
|
|
39
|
+
exclude: /node_modules/,
|
|
40
|
+
use: [
|
|
41
|
+
MiniCssExtractPlugin.loader,
|
|
42
|
+
{
|
|
43
|
+
loader: 'css-loader',
|
|
44
|
+
options: {
|
|
45
|
+
sourceMap: true,
|
|
46
|
+
url: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
loader: 'postcss-loader',
|
|
51
|
+
options: {
|
|
52
|
+
sourceMap: true,
|
|
53
|
+
postcssOptions: {
|
|
54
|
+
config: postcssConfig,
|
|
55
|
+
plugins: [['autoprefixer']],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
loader: 'sass-loader',
|
|
61
|
+
options: {
|
|
62
|
+
sourceMap: true,
|
|
63
|
+
sassOptions: {
|
|
64
|
+
importer: globImporter(),
|
|
65
|
+
outputStyle: 'compressed',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const SVGSpriteLoader = {
|
|
73
|
+
test: /icons\/.*\.svg$/, // your icons directory
|
|
74
|
+
loader: 'svg-sprite-loader',
|
|
75
|
+
options: {
|
|
76
|
+
extract: true,
|
|
77
|
+
runtimeCompat: true,
|
|
78
|
+
spriteFilename: './icons.svg',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
JSLoader,
|
|
84
|
+
CSSLoader,
|
|
85
|
+
SVGSpriteLoader,
|
|
86
|
+
ImageLoader,
|
|
87
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
2
|
+
const globImporter = require('node-sass-glob-importer');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
|
|
5
|
+
let babelConfig;
|
|
6
|
+
let postcssConfig;
|
|
7
|
+
|
|
8
|
+
// Check if custom babel config is available.
|
|
9
|
+
if (fs.existsSync('./config/babel.config.js')) {
|
|
10
|
+
babelConfig = './config/babel.config.js';
|
|
11
|
+
} else {
|
|
12
|
+
babelConfig = './node_modules/@emulsify/core/config/babel.config.js';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Check if custom postcss config is available.
|
|
16
|
+
if (fs.existsSync('./config/postcss.config.js')) {
|
|
17
|
+
postcssConfig = './config/postcss.config.js';
|
|
18
|
+
} else {
|
|
19
|
+
postcssConfig = './node_modules/@emulsify/core/config/postcss.config.js';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const JSLoader = {
|
|
23
|
+
test: /^(?!.*\.(stories|component)\.js$).*\.js$/,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
loader: 'babel-loader',
|
|
26
|
+
options: {
|
|
27
|
+
configFile: babelConfig,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ImageLoader = {
|
|
32
|
+
test: /\.(jpe?g|png|gif|svg)$/i,
|
|
33
|
+
exclude: /icons\/.*\.svg$/,
|
|
34
|
+
loader: 'file-loader',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const CSSLoader = {
|
|
38
|
+
test: /\.s[ac]ss$/i,
|
|
39
|
+
exclude: /node_modules/,
|
|
40
|
+
use: [
|
|
41
|
+
MiniCssExtractPlugin.loader,
|
|
42
|
+
{
|
|
43
|
+
loader: 'css-loader',
|
|
44
|
+
options: {
|
|
45
|
+
sourceMap: true,
|
|
46
|
+
url: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
loader: 'postcss-loader',
|
|
51
|
+
options: {
|
|
52
|
+
sourceMap: true,
|
|
53
|
+
postcssOptions: {
|
|
54
|
+
config: postcssConfig,
|
|
55
|
+
plugins: [['autoprefixer']],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
loader: 'sass-loader',
|
|
61
|
+
options: {
|
|
62
|
+
sourceMap: true,
|
|
63
|
+
sassOptions: {
|
|
64
|
+
importer: globImporter(),
|
|
65
|
+
outputStyle: 'compressed',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const SVGSpriteLoader = {
|
|
73
|
+
test: /icons\/.*\.svg$/, // your icons directory
|
|
74
|
+
loader: 'svg-sprite-loader',
|
|
75
|
+
options: {
|
|
76
|
+
extract: true,
|
|
77
|
+
runtimeCompat: true,
|
|
78
|
+
spriteFilename: './icons.svg',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
JSLoader,
|
|
84
|
+
CSSLoader,
|
|
85
|
+
SVGSpriteLoader,
|
|
86
|
+
ImageLoader,
|
|
87
|
+
};
|
|
@@ -9,14 +9,14 @@ let postcssConfig;
|
|
|
9
9
|
if (fs.existsSync('./config/babel.config.js')) {
|
|
10
10
|
babelConfig = './config/babel.config.js';
|
|
11
11
|
} else {
|
|
12
|
-
babelConfig = './node_modules/
|
|
12
|
+
babelConfig = './node_modules/@emulsify/core/config/babel.config.js';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// Check if custom postcss config is available.
|
|
16
16
|
if (fs.existsSync('./config/postcss.config.js')) {
|
|
17
17
|
postcssConfig = './config/postcss.config.js';
|
|
18
18
|
} else {
|
|
19
|
-
postcssConfig = './node_modules/
|
|
19
|
+
postcssConfig = './node_modules/@emulsify/core/config/postcss.config.js';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const JSLoader = {
|
|
@@ -59,6 +59,7 @@ const CSSLoader = {
|
|
|
59
59
|
{
|
|
60
60
|
loader: 'sass-loader',
|
|
61
61
|
options: {
|
|
62
|
+
api: "legacy",
|
|
62
63
|
sourceMap: true,
|
|
63
64
|
sassOptions: {
|
|
64
65
|
importer: globImporter(),
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
2
|
+
const globImporter = require('node-sass-glob-importer');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
|
|
5
|
+
let babelConfig;
|
|
6
|
+
let postcssConfig;
|
|
7
|
+
|
|
8
|
+
// Check if custom babel config is available.
|
|
9
|
+
if (fs.existsSync('./config/babel.config.js')) {
|
|
10
|
+
babelConfig = './config/babel.config.js';
|
|
11
|
+
} else {
|
|
12
|
+
babelConfig = './node_modules/@emulsify/core/config/babel.config.js';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Check if custom postcss config is available.
|
|
16
|
+
if (fs.existsSync('./config/postcss.config.js')) {
|
|
17
|
+
postcssConfig = './config/postcss.config.js';
|
|
18
|
+
} else {
|
|
19
|
+
postcssConfig = './node_modules/@emulsify/core/config/postcss.config.js';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const JSLoader = {
|
|
23
|
+
test: /^(?!.*\.(stories|component)\.js$).*\.js$/,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
loader: 'babel-loader',
|
|
26
|
+
options: {
|
|
27
|
+
configFile: babelConfig,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ImageLoader = {
|
|
32
|
+
test: /\.(png|svg|jpg|gif)$/i,
|
|
33
|
+
exclude: /icons\/.*\.svg$/,
|
|
34
|
+
loader: 'file-loader',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const CSSLoader = {
|
|
38
|
+
test: /\.s[ac]ss$/i,
|
|
39
|
+
exclude: /node_modules/,
|
|
40
|
+
use: [
|
|
41
|
+
MiniCssExtractPlugin.loader,
|
|
42
|
+
{
|
|
43
|
+
loader: 'css-loader',
|
|
44
|
+
options: {
|
|
45
|
+
sourceMap: true,
|
|
46
|
+
url: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
loader: 'postcss-loader',
|
|
51
|
+
options: {
|
|
52
|
+
sourceMap: true,
|
|
53
|
+
postcssOptions: {
|
|
54
|
+
config: postcssConfig,
|
|
55
|
+
plugins: [['autoprefixer']],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
loader: 'sass-loader',
|
|
61
|
+
options: {
|
|
62
|
+
api: 'legacy',
|
|
63
|
+
sourceMap: true,
|
|
64
|
+
sassOptions: {
|
|
65
|
+
importer: globImporter(),
|
|
66
|
+
outputStyle: 'compressed',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const SVGSpriteLoader = {
|
|
74
|
+
test: /icons\/.*\.svg$/, // your icons directory
|
|
75
|
+
loader: 'svg-sprite-loader',
|
|
76
|
+
options: {
|
|
77
|
+
extract: true,
|
|
78
|
+
runtimeCompat: true,
|
|
79
|
+
spriteFilename: './icons.svg',
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
module.exports = {
|
|
84
|
+
JSLoader,
|
|
85
|
+
CSSLoader,
|
|
86
|
+
SVGSpriteLoader,
|
|
87
|
+
ImageLoader,
|
|
88
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
5
|
+
const _MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
+
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
7
|
+
const _SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
|
|
8
|
+
const glob = require('glob');
|
|
9
|
+
|
|
10
|
+
const imagePath = path.resolve(__dirname, '../../../../../assets/images');
|
|
11
|
+
|
|
12
|
+
const MiniCssExtractPlugin = new _MiniCssExtractPlugin({
|
|
13
|
+
filename: '[name].css',
|
|
14
|
+
chunkFilename: '[id].css',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ImageminPlugin = new ImageMinimizerPlugin({
|
|
18
|
+
minimizer: {
|
|
19
|
+
implementation: ImageMinimizerPlugin.imageminMinify,
|
|
20
|
+
options: {
|
|
21
|
+
// Lossless optimization with custom option
|
|
22
|
+
// Feel free to experiment with options for better result for you
|
|
23
|
+
plugins: [
|
|
24
|
+
["gifsicle", { interlaced: true }],
|
|
25
|
+
["jpegtran", { progressive: true }],
|
|
26
|
+
["optipng", { optimizationLevel: 5 }],
|
|
27
|
+
// Svgo configuration here https://github.com/svg/svgo#configuration
|
|
28
|
+
[
|
|
29
|
+
"svgo",
|
|
30
|
+
{
|
|
31
|
+
plugins: [
|
|
32
|
+
{
|
|
33
|
+
name: "preset-default",
|
|
34
|
+
params: {
|
|
35
|
+
overrides: {
|
|
36
|
+
removeViewBox: false,
|
|
37
|
+
addAttributesToSVGElement: {
|
|
38
|
+
params: {
|
|
39
|
+
attributes: [
|
|
40
|
+
{ xmlns: "http://www.w3.org/2000/svg" },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const SpriteLoaderPlugin = new _SpriteLoaderPlugin({
|
|
56
|
+
plainSprite: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const ProgressPlugin = new webpack.ProgressPlugin();
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
ProgressPlugin,
|
|
63
|
+
MiniCssExtractPlugin,
|
|
64
|
+
ImageminPlugin,
|
|
65
|
+
SpriteLoaderPlugin,
|
|
66
|
+
CleanWebpackPlugin: new CleanWebpackPlugin({
|
|
67
|
+
protectWebpackAssets: false, // Required for removal of extra, unwanted dist/css/*.js files.
|
|
68
|
+
cleanOnceBeforeBuildPatterns: ['!*.{png,jpg,gif,svg}'],
|
|
69
|
+
cleanAfterEveryBuildPatterns: [
|
|
70
|
+
'remove/**',
|
|
71
|
+
'!js',
|
|
72
|
+
'css/**/*.js', // Remove all unwanted, auto generated JS files from dist/css folder.
|
|
73
|
+
'css/**/*.js.map',
|
|
74
|
+
'!*.{png,jpg,gif,svg}',
|
|
75
|
+
],
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
5
|
+
const _MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
+
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
7
|
+
const _SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
|
|
8
|
+
const glob = require('glob');
|
|
9
|
+
|
|
10
|
+
const imagePath = path.resolve(__dirname, '../../../../../assets/images');
|
|
11
|
+
|
|
12
|
+
const MiniCssExtractPlugin = new _MiniCssExtractPlugin({
|
|
13
|
+
filename: '[name].css',
|
|
14
|
+
chunkFilename: '[id].css',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ImageminPlugin = new ImageMinimizerPlugin({
|
|
18
|
+
minimizer: {
|
|
19
|
+
implementation: ImageMinimizerPlugin.imageminMinify,
|
|
20
|
+
options: {
|
|
21
|
+
// Lossless optimization with custom option
|
|
22
|
+
plugins: [
|
|
23
|
+
["gifsicle", { interlaced: true }],
|
|
24
|
+
["jpegtran", { progressive: true }],
|
|
25
|
+
["optipng", { optimizationLevel: 5 }],
|
|
26
|
+
// Svgo configuration here https://github.com/svg/svgo#configuration
|
|
27
|
+
[
|
|
28
|
+
"svgo",
|
|
29
|
+
{
|
|
30
|
+
plugins: [
|
|
31
|
+
{
|
|
32
|
+
name: "preset-default",
|
|
33
|
+
params: {
|
|
34
|
+
overrides: {
|
|
35
|
+
removeViewBox: false,
|
|
36
|
+
addAttributesToSVGElement: {
|
|
37
|
+
params: {
|
|
38
|
+
attributes: [
|
|
39
|
+
{ xmlns: "http://www.w3.org/2000/svg" },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const SpriteLoaderPlugin = new _SpriteLoaderPlugin({
|
|
55
|
+
plainSprite: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const ProgressPlugin = new webpack.ProgressPlugin();
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
ProgressPlugin,
|
|
62
|
+
MiniCssExtractPlugin,
|
|
63
|
+
ImageminPlugin,
|
|
64
|
+
SpriteLoaderPlugin,
|
|
65
|
+
CleanWebpackPlugin: new CleanWebpackPlugin({
|
|
66
|
+
protectWebpackAssets: false, // Required for removal of extra, unwanted dist/css/*.js files.
|
|
67
|
+
cleanOnceBeforeBuildPatterns: ['!*.{png,jpg,gif,svg}'],
|
|
68
|
+
cleanAfterEveryBuildPatterns: [
|
|
69
|
+
'remove/**',
|
|
70
|
+
'!js',
|
|
71
|
+
'css/**/*.js', // Remove all unwanted, auto generated JS files from dist/css folder.
|
|
72
|
+
'css/**/*.js.map',
|
|
73
|
+
'!*.{png,jpg,gif,svg}',
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
5
|
+
const _MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
+
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
7
|
+
const _SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
|
|
8
|
+
const glob = require('glob');
|
|
9
|
+
|
|
10
|
+
const imagePath = path.resolve(__dirname, '../../../../../assets/images');
|
|
11
|
+
|
|
12
|
+
const MiniCssExtractPlugin = new _MiniCssExtractPlugin({
|
|
13
|
+
filename: '[name].css',
|
|
14
|
+
chunkFilename: '[id].css',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ImageminPlugin = new ImageMinimizerPlugin({
|
|
18
|
+
minimizer: {
|
|
19
|
+
implementation: ImageMinimizerPlugin.imageminMinify,
|
|
20
|
+
options: {
|
|
21
|
+
// Lossless optimization with custom option
|
|
22
|
+
plugins: [
|
|
23
|
+
['gifsicle', { interlaced: true }],
|
|
24
|
+
['jpegtran', { progressive: true }],
|
|
25
|
+
['optipng', { optimizationLevel: 5 }],
|
|
26
|
+
// Svgo configuration here https://github.com/svg/svgo#configuration
|
|
27
|
+
[
|
|
28
|
+
"svgo",
|
|
29
|
+
{
|
|
30
|
+
plugins: [
|
|
31
|
+
{
|
|
32
|
+
name: "preset-default",
|
|
33
|
+
params: {
|
|
34
|
+
overrides: {
|
|
35
|
+
removeViewBox: false,
|
|
36
|
+
addAttributesToSVGElement: {
|
|
37
|
+
params: {
|
|
38
|
+
attributes: [
|
|
39
|
+
{ xmlns: "http://www.w3.org/2000/svg" },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const SpriteLoaderPlugin = new _SpriteLoaderPlugin({
|
|
55
|
+
plainSprite: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const ProgressPlugin = new webpack.ProgressPlugin();
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
ProgressPlugin,
|
|
62
|
+
MiniCssExtractPlugin,
|
|
63
|
+
ImageminPlugin,
|
|
64
|
+
SpriteLoaderPlugin,
|
|
65
|
+
CleanWebpackPlugin: new CleanWebpackPlugin({
|
|
66
|
+
protectWebpackAssets: false, // Required for removal of extra, unwanted dist/css/*.js files.
|
|
67
|
+
cleanOnceBeforeBuildPatterns: ['!*.{png,jpg,gif,svg}'],
|
|
68
|
+
cleanAfterEveryBuildPatterns: [
|
|
69
|
+
'remove/**',
|
|
70
|
+
'!js',
|
|
71
|
+
'css/**/*.js', // Remove all unwanted, auto generated JS files from dist/css folder.
|
|
72
|
+
'css/**/*.js.map',
|
|
73
|
+
'!*.{png,jpg,gif,svg}',
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
5
|
+
const _MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
|
+
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
|
|
7
|
+
const _SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
|
|
8
|
+
const glob = require('glob');
|
|
9
|
+
|
|
10
|
+
const imagePath = path.resolve(__dirname, '../../../../../assets/images');
|
|
11
|
+
|
|
12
|
+
const MiniCssExtractPlugin = new _MiniCssExtractPlugin({
|
|
13
|
+
filename: '[name].css',
|
|
14
|
+
chunkFilename: '[id].css',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ImageminPlugin = new ImageMinimizerPlugin({
|
|
18
|
+
minimizer: {
|
|
19
|
+
implementation: ImageMinimizerPlugin.imageminMinify,
|
|
20
|
+
options: {
|
|
21
|
+
// Lossless optimization with custom option
|
|
22
|
+
plugins: [
|
|
23
|
+
['gifsicle', { interlaced: true }],
|
|
24
|
+
['jpegtran', { progressive: true }],
|
|
25
|
+
['optipng', { optimizationLevel: 5 }],
|
|
26
|
+
// Svgo configuration here https://github.com/svg/svgo#configuration
|
|
27
|
+
[
|
|
28
|
+
"svgo",
|
|
29
|
+
{
|
|
30
|
+
plugins: [
|
|
31
|
+
{
|
|
32
|
+
name: "preset-default",
|
|
33
|
+
params: {
|
|
34
|
+
overrides: {
|
|
35
|
+
removeViewBox: false,
|
|
36
|
+
addAttributesToSVGElement: {
|
|
37
|
+
params: {
|
|
38
|
+
attributes: [
|
|
39
|
+
{ xmlns: "http://www.w3.org/2000/svg" },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const SpriteLoaderPlugin = new _SpriteLoaderPlugin({
|
|
55
|
+
plainSprite: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const ProgressPlugin = new webpack.ProgressPlugin();
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
ProgressPlugin,
|
|
62
|
+
MiniCssExtractPlugin,
|
|
63
|
+
ImageminPlugin,
|
|
64
|
+
SpriteLoaderPlugin,
|
|
65
|
+
CleanWebpackPlugin: new CleanWebpackPlugin({
|
|
66
|
+
protectWebpackAssets: false, // Required for removal of extra, unwanted dist/css/*.js files.
|
|
67
|
+
cleanOnceBeforeBuildPatterns: ['!*.{png,jpg,gif,svg}'],
|
|
68
|
+
cleanAfterEveryBuildPatterns: [
|
|
69
|
+
'remove/**',
|
|
70
|
+
'!js',
|
|
71
|
+
'css/**/*.js', // Remove all unwanted, auto generated JS files from dist/css folder.
|
|
72
|
+
'css/**/*.js.map',
|
|
73
|
+
'!*.{png,jpg,gif,svg}',
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
@@ -4,8 +4,8 @@ const loaders = require('./loaders');
|
|
|
4
4
|
const plugins = require('./plugins');
|
|
5
5
|
|
|
6
6
|
const webpackDir = path.resolve(__dirname);
|
|
7
|
-
const rootDir = path.resolve(__dirname, '
|
|
8
|
-
const distDir = path.resolve(__dirname, '
|
|
7
|
+
const rootDir = path.resolve(__dirname, '../../../../..');
|
|
8
|
+
const distDir = path.resolve(__dirname, '../../../../../dist');
|
|
9
9
|
|
|
10
10
|
// Glob pattern for scss files that ignore file names prefixed with underscore.
|
|
11
11
|
const scssPattern = path.resolve(rootDir, 'components/**/!(_*).scss');
|
|
@@ -60,11 +60,13 @@ module.exports = {
|
|
|
60
60
|
},
|
|
61
61
|
plugins: [
|
|
62
62
|
plugins.MiniCssExtractPlugin,
|
|
63
|
-
plugins.ImageminPlugin,
|
|
64
63
|
plugins.SpriteLoaderPlugin,
|
|
65
64
|
plugins.ProgressPlugin,
|
|
66
65
|
plugins.CleanWebpackPlugin,
|
|
67
66
|
],
|
|
67
|
+
optimization: [
|
|
68
|
+
plugins.ImageminPlugin,
|
|
69
|
+
],
|
|
68
70
|
output: {
|
|
69
71
|
path: distDir,
|
|
70
72
|
filename: '[name].js',
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const glob = require('glob');
|
|
3
|
+
const loaders = require('./loaders');
|
|
4
|
+
const plugins = require('./plugins');
|
|
5
|
+
|
|
6
|
+
const webpackDir = path.resolve(__dirname);
|
|
7
|
+
const rootDir = path.resolve(__dirname, '../../../../..');
|
|
8
|
+
const distDir = path.resolve(__dirname, '../../../../../dist');
|
|
9
|
+
|
|
10
|
+
// Glob pattern for scss files that ignore file names prefixed with underscore.
|
|
11
|
+
const scssPattern = path.resolve(rootDir, 'components/**/!(_*).scss');
|
|
12
|
+
// Glob pattern for JS files.
|
|
13
|
+
const jsPattern = path.resolve(
|
|
14
|
+
rootDir,
|
|
15
|
+
'components/**/!(*.stories|*.component|*.min|*.test).js',
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// Prepare list of scss and js file for "entry".
|
|
19
|
+
function getEntries(scssMatcher, jsMatcher) {
|
|
20
|
+
const entries = {};
|
|
21
|
+
|
|
22
|
+
// SCSS entries
|
|
23
|
+
glob.sync(scssMatcher).forEach((file) => {
|
|
24
|
+
const filePath = file.split('components/')[1];
|
|
25
|
+
const newfilePath = `css/${filePath.replace('.scss', '')}`;
|
|
26
|
+
entries[newfilePath] = file;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// JS entries
|
|
30
|
+
glob.sync(jsMatcher).forEach((file) => {
|
|
31
|
+
const filePath = file.split('components/')[1];
|
|
32
|
+
const newfilePath = `js/${filePath.replace('.js', '')}`;
|
|
33
|
+
entries[newfilePath] = file;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
entries.svgSprite = path.resolve(webpackDir, 'svgSprite.js');
|
|
37
|
+
|
|
38
|
+
// CSS Files.
|
|
39
|
+
glob.sync(`${webpackDir}/css/*js`).forEach((file) => {
|
|
40
|
+
const baseFileName = path.basename(file);
|
|
41
|
+
const newfilePath = `css/${baseFileName.replace('.js', '')}`;
|
|
42
|
+
entries[newfilePath] = file;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return entries;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
stats: {
|
|
50
|
+
errorDetails: true,
|
|
51
|
+
},
|
|
52
|
+
entry: getEntries(scssPattern, jsPattern),
|
|
53
|
+
module: {
|
|
54
|
+
rules: [
|
|
55
|
+
loaders.CSSLoader,
|
|
56
|
+
loaders.SVGSpriteLoader,
|
|
57
|
+
loaders.ImageLoader,
|
|
58
|
+
loaders.JSLoader,
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
plugins: [
|
|
62
|
+
plugins.MiniCssExtractPlugin,
|
|
63
|
+
plugins.SpriteLoaderPlugin,
|
|
64
|
+
plugins.ProgressPlugin,
|
|
65
|
+
plugins.CleanWebpackPlugin,
|
|
66
|
+
],
|
|
67
|
+
optimization: {
|
|
68
|
+
minimizer: [
|
|
69
|
+
plugins.ImageminPlugin
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
output: {
|
|
73
|
+
path: distDir,
|
|
74
|
+
filename: '[name].js',
|
|
75
|
+
},
|
|
76
|
+
};
|