Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #55

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
**/node_modules/
**/dist/
# intentionally not excluding .js files (no CI build yet)
**/yarn.lock
59 changes: 38 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exports.__esModule = true;
exports.provideConfiguration = exports.CommonPathPatterns_v1 = exports.SimpleWebPackConfig_v1_Paths_DEFAULT = void 0;
var path = require("path");
var MiniCssExtractPlugin = require("mini-css-extract-plugin");
var ImageminPlugin = require("imagemin-webpack");
var ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
exports.SimpleWebPackConfig_v1_Paths_DEFAULT = {
applicationEntryPointFile: "src/index.js",
distributionDirectory: "dist",
Expand All @@ -21,6 +21,7 @@ function provideConfiguration(config, projectAbsoluteRootPath) {
var evaluate = function (production) {
var rules = [];
var plugins = [];
var minimizers = [];
if (config.scripts.enabled) {
var scriptsOnlyTest = /\.jsx?$/;
rules.push({
Expand Down Expand Up @@ -111,21 +112,35 @@ function provideConfiguration(config, projectAbsoluteRootPath) {
});
if (config.images.optimize) {
// Make sure that the plugin is after any plugins that add images, example `CopyWebpackPlugin`
plugins.push(new ImageminPlugin({
bail: false,
cache: true,
imageminOptions: {
// Lossless optimization with custom option
// Feel free to experement with options for better result for you
plugins: [
['gifsicle', { interlaced: true }],
['mozjpeg', {
progressive: true,
quality: 75
}],
['optipng', { optimizationLevel: 5 }],
['svgo', { removeViewBox: true }],
]
minimizers.push(new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.imageminMinify,
options: {
bail: false,
cache: true,
// Lossless optimization with custom option
// Feel free to experement with options for better result for you
plugins: [
['gifsicle', { interlaced: true }],
['mozjpeg', {
progressive: true,
quality: 75
}],
['optipng', { optimizationLevel: 5 }],
['svgo', {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: true
}
}
}
]
}],
]
}
}
}));
}
Expand All @@ -144,7 +159,7 @@ function provideConfiguration(config, projectAbsoluteRootPath) {
}
});
}
return { rules: rules, plugins: plugins };
return { rules: rules, plugins: plugins, minimizers: minimizers };
};
var absolutize = function (relative) {
return path.resolve(projectAbsoluteRootPath, relative);
Expand All @@ -159,15 +174,17 @@ function provideConfiguration(config, projectAbsoluteRootPath) {
},
devtool: isProduction ? "source-map" : "inline-source-map",
devServer: {
// The bundled files will be available in the browser under this path...
publicPath: "/" + path.relative(absolutize(config.paths.publicContentRoot), absolutize(config.paths.distributionDirectory)),
// Tell the server where to serve content from.
contentBase: absolutize(config.paths.publicContentRoot)
static: [{
directory: absolutize(config.paths.publicContentRoot)
}]
},
module: {
rules: result.rules
},
plugins: result.plugins,
optimization: {
minimizer: result.minimizers
},
resolve: {
extensions: ['.ts', '.js', '.json', '.css', '.scss']
}
Expand Down
72 changes: 43 additions & 29 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as webpack from "webpack";

Check failure on line 1 in index.ts

View workflow job for this annotation

GitHub Actions / tests (14.x)

Cannot find module 'webpack' or its corresponding type declarations.

Check failure on line 1 in index.ts

View workflow job for this annotation

GitHub Actions / tests (15.x)

Cannot find module 'webpack' or its corresponding type declarations.

Check failure on line 1 in index.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Cannot find module 'webpack' or its corresponding type declarations.
import * as path from "path";

Check failure on line 2 in index.ts

View workflow job for this annotation

GitHub Actions / tests (14.x)

Cannot find module 'path' or its corresponding type declarations.

Check failure on line 2 in index.ts

View workflow job for this annotation

GitHub Actions / tests (15.x)

Cannot find module 'path' or its corresponding type declarations.

Check failure on line 2 in index.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Cannot find module 'path' or its corresponding type declarations.

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

Check failure on line 4 in index.ts

View workflow job for this annotation

GitHub Actions / tests (14.x)

Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

Check failure on line 4 in index.ts

View workflow job for this annotation

GitHub Actions / tests (15.x)

Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

Check failure on line 4 in index.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
const ImageminPlugin = require("imagemin-webpack");
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");

Check failure on line 5 in index.ts

View workflow job for this annotation

GitHub Actions / tests (14.x)

Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

Check failure on line 5 in index.ts

View workflow job for this annotation

GitHub Actions / tests (15.x)

Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

Check failure on line 5 in index.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

export interface SimpleWebPackConfig_v1_Paths {
/**
Expand Down Expand Up @@ -74,10 +74,12 @@

const evaluate = (production: boolean): {
rules: webpack.RuleSetRule[],
plugins: webpack.WebpackPluginInstance[]
plugins: webpack.WebpackPluginInstance[],
minimizers: webpack.WebpackPluginInstance[],
} => {
const rules: webpack.RuleSetRule[] = [];
const plugins: webpack.WebpackPluginInstance[] = [];
const minimizers: webpack.WebpackPluginInstance[] = [];

if (config.scripts.enabled) {
const scriptsOnlyTest = /\.jsx?$/;
Expand Down Expand Up @@ -181,24 +183,38 @@

if (config.images.optimize) {
// Make sure that the plugin is after any plugins that add images, example `CopyWebpackPlugin`
plugins.push(
new ImageminPlugin({
bail: false, // Ignore errors on corrupted images
cache: true,
imageminOptions: {
// Lossless optimization with custom option
// Feel free to experement with options for better result for you
plugins: [
['gifsicle', {interlaced: true}],
['mozjpeg', {
progressive: true,
quality: 75,
}],
['optipng', {optimizationLevel: 5}],
['svgo', {removeViewBox: true}],
]
}
})
minimizers.push(
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.imageminMinify,
options: {
bail: false, // Ignore errors on corrupted images
cache: true,
// Lossless optimization with custom option
// Feel free to experement with options for better result for you
plugins: [
['gifsicle', {interlaced: true}],
['mozjpeg', {
progressive: true,
quality: 75,
}],
['optipng', {optimizationLevel: 5}],
['svgo', {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: true,
},
},
},
],
}],
],
},
},
}),
);
}
}
Expand All @@ -218,7 +234,7 @@
});
}

return { rules, plugins };
return { rules, plugins, minimizers };
};

const absolutize = (relative: string): string =>
Expand All @@ -235,19 +251,17 @@
},
devtool: isProduction ? "source-map" : "inline-source-map",
devServer: {
// The bundled files will be available in the browser under this path...
publicPath: "/" + path.relative(
absolutize(config.paths.publicContentRoot),
absolutize(config.paths.distributionDirectory)
),

// Tell the server where to serve content from.
contentBase: absolutize(config.paths.publicContentRoot),
static: [{
directory: absolutize(config.paths.publicContentRoot),
}],
},
module: {
rules: result.rules
},
plugins: result.plugins,
optimization: {
minimizer: result.minimizers,
},
resolve: {
extensions: ['.ts', '.js', '.json', '.css', '.scss'],
}
Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,35 @@
"test": "cd tests && bash run.sh"
},
"dependencies": {
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@types/node": "^16.3.1",
"@babel/core": "^7.16.5",
"@babel/preset-env": "^7.16.5",
"@types/node": "^16.11.13",
"@types/webpack": "^5.28.0",
"babel-loader": "^8.0.5",
"css-loader": "^6.2.0",
"babel-loader": "^8.2.3",
"css-loader": "^6.5.1",
"file-loader": "^6.2.0",
"image-minimizer-webpack-plugin": "^3.0.1",
"imagemin": "^8.0.1",
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^7.0.0",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-optipng": "^8.0.0",
"imagemin-pngquant": "^9.0.2",
"imagemin-svgo": "^9.0.0",
"imagemin-webpack": "^5.1.1",
"mini-css-extract-plugin": "^2.1.0",
"node-sass": "^6.0.1",
"postcss-loader": "^6.1.1",
"postcss-preset-env": "^6.6.0",
"imagemin-svgo": "^10.0.0",
"mini-css-extract-plugin": "^2.4.5",
"postcss": "^8.4.5",
"postcss-loader": "^6.2.1",
"postcss-preset-env": "^7.0.1",
"resolve-url-loader": "^4.0.0",
"sass-loader": "^12.1.0",
"style-loader": "^3.0.0",
"ts-loader": "^9.2.3",
"ts-node": "^10.1.0",
"typescript": "^4.3.5",
"webpack": "^5.44.0",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.10.1"
"sass": "^1.45.0",
"sass-loader": "^12.4.0",
"style-loader": "^3.3.1",
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"typescript": "^4.5.4",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.6.0"
},
"engineStrict": true,
"engines": {
Expand Down
Loading
Loading