Skip to content

Commit 441d8ec

Browse files
committed
Update webpack
1 parent 97a68dd commit 441d8ec

File tree

11 files changed

+89
-185
lines changed

11 files changed

+89
-185
lines changed

.babelrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"presets": ["react", "es2015", "stage-0"],
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": ["@babel/plugin-proposal-class-properties"],
34
"env": {
45
"development": {
5-
"presets": ["react-hmre"]
6+
"presets": []
67
},
78
"test": {
89
"plugins": ["rewire"]

.browserslistrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> 1%

demo/client/components/DemoEditor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component } from 'react';
22
import Editor from 'draft-js-plugins-editor';
33

4-
import createMarkdownShortcutsPlugin from 'draft-js-markdown-shortcuts-plugin'; // eslint-disable-line
54
import Draft, {
65
convertToRaw,
76
// convertFromRaw,
@@ -22,6 +21,7 @@ import 'prismjs/components/prism-ruby';
2221
import 'prismjs/components/prism-swift';
2322
import createPrismPlugin from 'draft-js-prism-plugin';
2423
import styles from './styles.css';
24+
import createMarkdownShortcutsPlugin from '../../../..'; // eslint-disable-line
2525

2626
const prismPlugin = createPrismPlugin({
2727
prism: Prism,

demo/index.html.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

demo/publicTemplate/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
7+
<title>draft-js-markdown-shortcuts-plugin Demo</title>
8+
<link rel="stylesheet" href="./css/normalize.css"/>
9+
<link rel="stylesheet" href="./css/base.css"/>
10+
<link rel="stylesheet" href="./css/Draft.css"/>
11+
<link rel="stylesheet" href="./css/prism.css"/>
12+
<link rel="stylesheet" href="./css/CheckableListItem.css"/>
13+
<link rel="stylesheet" href="./app.css"/>
14+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:700,300,700i,300i" rel="stylesheet" type="text/css"/>
15+
<link href='https://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
16+
<link href="//cdn-images.mailchimp.com/embedcode/horizontal-slim-10_7.css" rel="stylesheet" type="text/css" />
17+
</head>
18+
<body>
19+
<div id="root"></div>
20+
<script src="./app.js"></script>
21+
</body>
22+
</html>

demo/server.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

demo/webpack.config.base.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

demo/webpack.config.dev.js

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
1-
/* eslint-disable no-var */
2-
var path = require('path');
3-
var webpack = require('webpack');
4-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5-
var webpackBaseConfig = require('./webpack.config.base');
6-
7-
// Set up dev host and HMR host. For the dev host this is pretty self
8-
// explanatory: We use a different live-reload server to serve our static JS
9-
// files in dev, so we need to be able to actually point a script tag to that
10-
// host so it can load the right files. The HMR host is a bit stranger. For more
11-
// details on why we need this URL see the readme and:
12-
// https://github.com/glenjamin/webpack-hot-middleware/issues/37
13-
var DEV_PORT = process.env.DEV_PORT || 3001;
14-
var DEV_HOST = `//localhost:${DEV_PORT}/`;
15-
var HMR_HOST = `${DEV_HOST}__webpack_hmr`;
16-
17-
module.exports = Object.assign(webpackBaseConfig, {
18-
devtool: 'inline-source-map',
1+
const path = require('path');
192

3+
module.exports = {
4+
mode: 'development',
205
entry: {
21-
app: [
22-
`webpack-hot-middleware/client?path=${HMR_HOST}`,
23-
'babel-polyfill',
24-
path.join(__dirname, 'client', 'index.js'),
25-
],
6+
app: path.join(__dirname, 'client/index.js'),
267
},
27-
288
output: {
29-
path: path.join(__dirname, 'public'),
9+
path: path.resolve(__dirname, 'public'),
3010
filename: '[name].js',
31-
publicPath: DEV_HOST,
3211
},
33-
34-
plugins: [
35-
new ExtractTextPlugin('css/bundle.css', { disable: true }),
36-
new webpack.HotModuleReplacementPlugin(),
37-
new webpack.NoErrorsPlugin(),
38-
],
39-
});
12+
module: {
13+
rules: [
14+
{
15+
test: /\.js$/,
16+
exclude: /node_modules/,
17+
loader: 'babel-loader',
18+
},
19+
{
20+
test: /\.css$/,
21+
use: ['style-loader', 'css-loader', 'postcss-loader'],
22+
},
23+
],
24+
},
25+
devServer: {
26+
contentBase: [path.join(__dirname, 'public'), path.join(__dirname, 'publicTemplate')],
27+
port: process.env.PORT || 3001,
28+
},
29+
};

demo/webpack.config.prod.js

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
1-
/* eslint-disable no-var */
2-
var path = require('path');
3-
var webpack = require('webpack');
4-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5-
var StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
6-
var webpackBaseConfig = require('./webpack.config.base');
7-
8-
module.exports = Object.assign(webpackBaseConfig, {
9-
devtool: 'source-map',
1+
const path = require('path');
102

3+
module.exports = {
4+
mode: 'production',
115
entry: {
12-
app: [path.join(__dirname, 'client', 'index.js')],
13-
main: [path.join(__dirname, 'index.html.js')],
6+
app: path.join(__dirname, 'client/index.js'),
147
},
15-
168
output: {
17-
path: path.join(__dirname, 'public'),
18-
filename: '[name].js',
19-
libraryTarget: 'umd',
20-
publicPath: '/',
9+
path: path.resolve(__dirname, 'public'),
10+
filename: '[name].[hash].js',
2111
},
22-
23-
plugins: [
24-
new ExtractTextPlugin('[name].css', { allChunks: true }),
25-
new webpack.optimize.OccurenceOrderPlugin(),
26-
new webpack.DefinePlugin({
27-
'process.env': {
28-
NODE_ENV: JSON.stringify('production'),
12+
module: {
13+
rules: [
14+
{
15+
test: /\.js$/,
16+
exclude: /node_modules/,
17+
loader: 'babel-loader',
2918
},
30-
}),
31-
new webpack.optimize.UglifyJsPlugin({
32-
screw_ie8: true,
33-
compressor: { warnings: false },
34-
}),
35-
new StaticSiteGeneratorPlugin('main', ['/'], {}),
36-
],
37-
});
19+
{
20+
test: /\.css$/,
21+
use: ['style-loader', 'css-loader', 'postcss-loader'],
22+
},
23+
],
24+
},
25+
devServer: {
26+
contentBase: [path.join(__dirname, 'public'), path.join(__dirname, 'publicTemplate')],
27+
port: process.env.PORT || 3001,
28+
},
29+
};

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"scripts": {
77
"eslint": "node_modules/.bin/eslint .",
88
"build": "npm run clean && npm run build:js",
9-
"build:demo": "NODE_ENV=production npx webpack --config demo/webpack.config.prod.js && rm -rf demo/public/css && cp -R demo/publicTemplate/* demo/public/",
9+
"build:demo": "rm -rf demo/public/* && NODE_ENV=production npx webpack --config demo/webpack.config.prod.js && rm -rf demo/public/{css,index.html} && cp -R demo/publicTemplate/* demo/public/ && sed \"s/app.js/$(basename $(ls demo/public/app.*.js))/g\" demo/publicTemplate/index.html > demo/public/index.html",
1010
"build:js": "BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production node_modules/.bin/babel --out-dir='lib' --ignore='**/__test__/*' src",
1111
"clean": "node_modules/.bin/rimraf lib; node_modules/.bin/rimraf demo/public",
1212
"prepare": "npm run build",
1313
"prepublish": "npm run build",
1414
"start": "npm run start:dev",
1515
"start:dev": "node_modules/.bin/babel-node ./demo/server.js",
1616
"test": "npm run test:coverage",
17-
"test:coverage": "node_modules/.bin/nyc --require babel-core/register npm run test:mocha",
17+
"test:coverage": "node_modules/.bin/nyc --require @babel/register npm run test:mocha",
1818
"test:mocha": "BABEL_ENV=test mocha",
1919
"test:watch": "npm test | npm run watch",
2020
"watch": "npm-watch",
@@ -37,17 +37,19 @@
3737
},
3838
"homepage": "https://github.com/ngs/draft-js-markdown-shortcuts-plugin#readme",
3939
"devDependencies": {
40+
"@babel/cli": "^7.10.1",
41+
"@babel/core": "^7.10.2",
42+
"@babel/plugin-proposal-class-properties": "^7.10.1",
43+
"@babel/polyfill": "^7.10.1",
44+
"@babel/preset-env": "^7.10.2",
45+
"@babel/preset-es2015": "^7.0.0-beta.53",
46+
"@babel/preset-react": "^7.10.1",
47+
"@babel/preset-stage-0": "^7.8.3",
48+
"@babel/register": "^7.10.1",
4049
"autoprefixer": "^9.8.0",
41-
"babel-cli": "^6.26.0",
42-
"babel-core": "^6.26.3",
4350
"babel-eslint": "^10.1.0",
4451
"babel-loader": "^8.1.0",
4552
"babel-plugin-rewire": "^1.2.0",
46-
"babel-polyfill": "^6.26.0",
47-
"babel-preset-es2015": "^6.24.1",
48-
"babel-preset-react": "^6.24.1",
49-
"babel-preset-react-hmre": "^1.1.1",
50-
"babel-preset-stage-0": "^6.24.1",
5153
"chai": "^4.2.0",
5254
"chai-enzyme": "^1.0.0-beta.1",
5355
"cheerio": "^0.22.0",
@@ -66,7 +68,6 @@
6668
"eslint-plugin-jsx-a11y": "6.2.3",
6769
"eslint-plugin-mocha": "^7.0.1",
6870
"eslint-plugin-react": "^7.20.0",
69-
"express": "^4.17.1",
7071
"extract-text-webpack-plugin": "^3.0.2",
7172
"file-loader": "^6.0.0",
7273
"flow-bin": "^0.125.1",
@@ -89,12 +90,11 @@
8990
"rimraf": "^3.0.2",
9091
"sinon": "^9.0.2",
9192
"sinon-chai": "^3.5.0",
92-
"static-site-generator-webpack-plugin": "^3.4.2",
9393
"style-loader": "^1.2.1",
9494
"url-loader": "^4.1.0",
9595
"webpack": "~4.43.0",
96-
"webpack-dev-middleware": "^3.7.2",
97-
"webpack-hot-middleware": "^2.25.0"
96+
"webpack-cli": "^3.3.11",
97+
"webpack-dev-server": "^3.11.0"
9898
},
9999
"peerDependencies": {
100100
"draft-js-plugins-editor": "^3.0.0",

0 commit comments

Comments
 (0)