Skip to content

Commit 59713d6

Browse files
committed
Update the webpack config and npm dependencies.
1 parent 25363f3 commit 59713d6

4 files changed

Lines changed: 46 additions & 111 deletions

File tree

.babelrc

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
11
{
2-
"presets": [
3-
[ "env", {
4-
"modules": false,
5-
"targets": {
6-
"browsers": [
7-
"last 2 Chrome versions",
8-
"last 2 Firefox versions",
9-
"last 2 Safari versions",
10-
"last 2 Edge versions",
11-
"last 2 Opera versions",
12-
"last 2 iOS versions",
13-
"last 1 Android version",
14-
"last 1 ChromeAndroid version",
15-
"ie 11",
16-
"> 1%"
17-
]
18-
}
19-
} ]
20-
],
21-
"plugins": [
22-
"transform-object-rest-spread",
23-
[ "transform-react-jsx", {
24-
"pragma": "wp.element.createElement"
25-
} ]
26-
],
27-
"env": {
28-
"default": {
29-
"plugins": [
30-
"transform-runtime"
31-
]
32-
},
33-
"test": {
34-
"presets": [ "env" ]
35-
},
36-
"gettext": {
37-
"plugins": [
38-
[ "./i18n/babel-plugin", {
39-
"output": "languages/shiny-code.pot"
40-
} ]
41-
]
42-
}
43-
}
2+
"presets": [ "@wordpress/default" ]
443
}

blocks/code/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './editor.scss';
2-
31
import classnames from 'classnames';
42
import { blocks, i18n } from 'wp';
53
import CodeBlockEdit from './edit';

package.json

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,28 @@
66
"license": "GPL-2.0-or-later",
77
"repository": "cedaro/shiny-code",
88
"dependencies": {
9-
"classnames": "^2.2.5"
9+
"classnames": "^2.2.6"
1010
},
1111
"devDependencies": {
12-
"archiver": "^3.0.0",
13-
"autoprefixer": "^9.0.2",
14-
"babel-core": "^6.26.0",
15-
"babel-loader": "^7.1.5",
16-
"babel-plugin-lodash": "3.3.4",
17-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
18-
"babel-plugin-transform-react-jsx": "6.24.1",
19-
"babel-plugin-transform-runtime": "6.23.0",
20-
"babel-preset-env": "^1.6.0",
21-
"extract-text-webpack-plugin": "^4.0.0-beta.0",
22-
"fs-extra": "^7.0.0",
23-
"glob": "^7.1.2",
24-
"minimist": "^1.2.0",
25-
"node-sass": "4.11.0",
26-
"node-wp-i18n": "^1.2.0",
27-
"postcss-loader": "^3.0.0",
28-
"raw-loader": "^1.0.0",
29-
"sass-loader": "^7.1.0",
30-
"style-loader": "^0.23.1",
31-
"webpack": "^4.16.3",
32-
"webpack-cli": "^3.1.0"
12+
"@babel/core": "^7.13.8",
13+
"@wordpress/babel-preset-default": "^5.0.1",
14+
"archiver": "^5.2.0",
15+
"autoprefixer": "^10.2.4",
16+
"babel-loader": "^8.2.2",
17+
"css-loader": "^5.1.0",
18+
"fs-extra": "^9.1.0",
19+
"glob": "^7.1.6",
20+
"mini-css-extract-plugin": "^1.3.9",
21+
"minimist": "^1.2.5",
22+
"node-wp-i18n": "^1.2.5",
23+
"postcss": "^8.2.6",
24+
"postcss-loader": "^5.0.0",
25+
"sass": "^1.32.8",
26+
"sass-loader": "^11.0.1",
27+
"style-loader": "^2.0.0",
28+
"webpack": "^5.24.2",
29+
"webpack-cli": "^4.5.0",
30+
"webpack-remove-empty-scripts": "^0.7.1"
3331
},
3432
"scripts": {
3533
"build": "BABEL_ENV=default NODE_ENV=production webpack",

webpack.config.js

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,21 @@
11
const webpack = require( 'webpack' );
2-
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
2+
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
3+
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
34
const mode = process.env.NODE_ENV || 'development';
45

5-
const editorCSSPlugin = new ExtractTextPlugin( {
6-
filename: 'build/css/editor.css'
7-
} );
8-
9-
const themesCSSPlugin = new ExtractTextPlugin( {
10-
filename: 'build/[name]'
11-
} );
12-
13-
const extractConfig = {
14-
use: [
15-
{ loader: 'raw-loader' },
16-
{
17-
loader: 'postcss-loader',
18-
options: {
19-
plugins: [
20-
require( 'autoprefixer' ),
21-
],
22-
},
23-
},
24-
{
25-
loader: 'sass-loader'
26-
},
27-
],
28-
};
29-
306
const config = {
317
mode: mode,
328
entry: {
33-
'js/editor.js': './blocks/editor.js',
34-
'css/themes/atom-one-dark/prism.css': './blocks/code/scss/themes/atom-one-dark/prism.scss',
35-
'css/themes/atom-one-light/prism.css': './blocks/code/scss/themes/atom-one-light/prism.scss',
36-
'css/themes/atom-one-dark/codemirror.css': './blocks/code/scss/themes/atom-one-dark/codemirror.scss',
37-
'css/themes/atom-one-light/codemirror.css': './blocks/code/scss/themes/atom-one-light/codemirror.scss'
9+
'js/editor': './blocks/editor.js',
10+
'css/editor': './blocks/code/editor.scss',
11+
'css/themes/atom-one-dark/prism': './blocks/code/scss/themes/atom-one-dark/prism.scss',
12+
'css/themes/atom-one-light/prism': './blocks/code/scss/themes/atom-one-light/prism.scss',
13+
'css/themes/atom-one-dark/codemirror': './blocks/code/scss/themes/atom-one-dark/codemirror.scss',
14+
'css/themes/atom-one-light/codemirror': './blocks/code/scss/themes/atom-one-light/codemirror.scss'
3815
},
3916
output: {
4017
path: __dirname,
41-
filename: 'build/[name]'
18+
filename: 'build/[name].js'
4219
},
4320
externals: {
4421
_: '_',
@@ -54,25 +31,28 @@ const config = {
5431
exclude: /node_modules/,
5532
use: 'babel-loader'
5633
},
57-
{
58-
test: /editor\.s?css$/,
59-
include: [
60-
/blocks/,
61-
],
62-
use: editorCSSPlugin.extract( extractConfig ),
63-
},
6434
{
6535
test: /.*\.scss$/,
66-
include: [
67-
/scss\/themes/,
68-
],
69-
use: themesCSSPlugin.extract( extractConfig ),
36+
use: [
37+
MiniCssExtractPlugin.loader,
38+
{
39+
loader: 'css-loader'
40+
},
41+
{
42+
loader: 'postcss-loader'
43+
},
44+
{
45+
loader: 'sass-loader'
46+
}
47+
]
7048
}
7149
]
7250
},
7351
plugins: [
74-
editorCSSPlugin,
75-
themesCSSPlugin,
52+
new RemoveEmptyScriptsPlugin(),
53+
new MiniCssExtractPlugin( {
54+
filename: 'build/[name].css'
55+
} )
7656
]
7757
};
7858

0 commit comments

Comments
 (0)