Skip to content

Commit 178710a

Browse files
Merge branch 'release/1.2.2'
2 parents 091311b + ab6d63c commit 178710a

File tree

4 files changed

+82
-12832
lines changed

4 files changed

+82
-12832
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## 1.2.2
5+
6+
* [Added] TypeScript support
7+
* [Added] Alias configuration for easier imports
8+
* [Added] Minimizer config to preserve class names
9+
410
## 1.2.1
511

612
* [Added] Missing babel options

config/webpack.config.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* External dependencies
33
*/
4-
const { existsSync, lstatSync, readdirSync, realpathSync } = require('fs');
5-
const { sync: readPkgUp } = require('read-pkg-up');
4+
const { existsSync, lstatSync, readdirSync } = require('fs');
65
const globImporter = require('node-sass-glob-importer');
76
const LiveReloadPlugin = require('webpack-livereload-plugin');
87
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
98
const path = require('path');
9+
const TerserPlugin = require('terser-webpack-plugin');
1010

1111
/**
1212
* WordPress dependencies
@@ -19,16 +19,15 @@ const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extract
1919
const RemoveSuprefluousAssetsPlugin = require('../plugins/remove-superfluous-assets');
2020
const {
2121
getArg,
22+
getPackagePath,
2223
getScriptsConfig,
2324
hasArg,
2425
hasBabelConfig,
2526
hasFileArg,
2627
hasPostCSSConfig,
2728
} = require('../utils');
2829

29-
const { path: pkgPath } = readPkgUp({
30-
cwd: realpathSync(process.cwd()),
31-
});
30+
const pkgPath = getPackagePath();
3231

3332
const config = getScriptsConfig();
3433

@@ -125,6 +124,14 @@ if (!hasFileArg()) {
125124
}
126125
}
127126

127+
const alias = Object.fromEntries(
128+
Object.entries(paths)
129+
.filter(([key]) =>
130+
['scripts', 'styles', 'images', 'fonts'].includes(key)
131+
)
132+
.map(([, value]) => [value, `${paths.src}/${value}`])
133+
);
134+
128135
const mode = getArg(
129136
'--mode',
130137
process.env.NODE_ENV === 'production' ? 'production' : 'development'
@@ -148,11 +155,16 @@ module.exports = {
148155
filename: '[name].js',
149156
publicPath: '../',
150157
},
158+
resolve: {
159+
alias,
160+
extensions: ['.ts', '.tsx', '...'],
161+
roots: [path.resolve(pkgPath)],
162+
},
151163
devtool: isProduction ? false : 'source-map',
152164
module: {
153165
rules: [
154166
{
155-
test: /\.js$/,
167+
test: /\.(t|j)sx?$/,
156168
exclude: /node_modules/,
157169
use: [
158170
require.resolve('thread-loader'),
@@ -267,6 +279,16 @@ module.exports = {
267279
},
268280
],
269281
},
282+
optimization: {
283+
minimize: true,
284+
minimizer: [
285+
new TerserPlugin({
286+
terserOptions: {
287+
keep_classnames: true,
288+
},
289+
}),
290+
],
291+
},
270292
plugins: [
271293
new MiniCssExtractPlugin({
272294
filename: '[name].css',

0 commit comments

Comments
 (0)