Skip to content

Commit 8f6aac4

Browse files
author
Dominic Coelho
committed
First draft of working mdx support with webpack:
- `node_modules/.bin/webpack` to build dist - `yarn start` to run on localhost
1 parent 03868e8 commit 8f6aac4

File tree

8 files changed

+126
-9
lines changed

8 files changed

+126
-9
lines changed

.babelrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"presets": ["@babel/preset-env", "@babel/preset-react"],
33
"plugins": [
44
"@babel/plugin-proposal-object-rest-spread",
5-
"@babel/plugin-proposal-class-properties",
6-
"babel-plugin-emotion"
5+
"@babel/plugin-proposal-class-properties"
76
],
87
"env": {
98
"esm": {

dist/bundle.js

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Getting Started - Spectacle</title>
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
<script type="text/javascript" src="bundle.js"></script></body>
9+
</html>

index.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Getting Started - Spectacle</title>
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
</body>
9+
</html>

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render } from 'react-dom';
3+
import MDXDocument from './test.mdx';
34

4-
import Presentation from './example/src';
5-
6-
render(<Presentation />, document.getElementById('root'));
5+
// const Zip = () => <div>boop</div>;
6+
render(<MDXDocument />, document.getElementById('root'));

package.json

+21-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"prettier": "prettier \"**/*.{js,json,ts,css,md}\"",
1313
"prettier-fix": "npm run prettier -- --write",
1414
"deploy": "",
15-
"start": "",
15+
"start": "builder run --env \"{\\\"BABEL_ENV\\\":\\\"esm\\\"}\" build-wds-base -- --port=3000 --hot",
16+
"build-wds-base": "webpack-dev-server",
1617
"test": "jest --verbose",
1718
"check": ""
1819
},
@@ -22,25 +23,41 @@
2223
"type": "git",
2324
"url": "https://github.com/FormidableLabs/spectacle.git"
2425
},
25-
"dependencies": {},
26+
"browserslist": "> 0.25%, not dead",
27+
"dependencies": {
28+
"webpack": "^4.33.0",
29+
"webpack-dev-server": "^3.7.1"
30+
},
2631
"peerDependencies": {
2732
"prop-types": "^15.6.2",
2833
"react": "^16.7.0",
2934
"react-dom": "^16.7.0"
3035
},
3136
"devDependencies": {
37+
"@babel/cli": "^7.4.4",
38+
"@babel/core": "^7.4.5",
39+
"@babel/plugin-proposal-class-properties": "^7.4.4",
40+
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
41+
"@babel/polyfill": "^7.4.4",
42+
"@babel/preset-env": "^7.4.5",
43+
"@babel/preset-react": "^7.0.0",
44+
"@mdx-js/loader": "^1.0.0-rc.4",
45+
"babel-loader": "^8.0.6",
46+
"builder": "^4.0.0",
3247
"eslint": "^4.19.0",
3348
"eslint-config-formidable": "^3.0.0",
3449
"eslint-config-prettier": "^2.9.0",
3550
"eslint-plugin-filenames": "^1.2.0",
3651
"eslint-plugin-import": "^2.9.0",
3752
"eslint-plugin-react": "^7.7.0",
53+
"html-webpack-plugin": "^3.2.0",
3854
"prettier": "^1.15.3",
3955
"prop-types": "^15.6.2",
4056
"raw-loader": "^1.0.0",
4157
"react": "^16.7.0",
4258
"react-dom": "^16.7.0",
4359
"tslint": "^5.12.1",
44-
"typescript": "^3.2.2"
60+
"typescript": "^3.2.2",
61+
"webpack-cli": "^3.3.4"
4562
}
46-
}
63+
}

test.mdx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Hello, _world_!
2+
3+
Below is an example of JSX embedded in Markdown. <br /> **Kara and dom were successful!**
4+
5+
<div style={{ padding: '20px', backgroundColor: 'aliceblue' }}>
6+
<h3>This is JSX</h3>
7+
</div>
8+
9+
- One ah ah ah
10+
- Two ah ah ah
11+
- Two point five
12+
- Three
13+
14+
## Code snippet test
15+
16+
const hello = "hi";
17+
18+
```js
19+
const hi = 'hello';
20+
```

webpack.config.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const path = require('path');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
4+
module.exports = {
5+
entry: './index.js',
6+
output: {
7+
path: path.join(__dirname, 'dist'),
8+
filename: 'bundle.js'
9+
},
10+
module: {
11+
rules: [
12+
{
13+
test: /\.js$/,
14+
// include: ['index.js', 'src', 'example/assets', 'example/src'].map(
15+
// name => path.resolve(__dirname, name)
16+
// ),
17+
use: {
18+
loader: 'babel-loader',
19+
options: {
20+
presets: ['@babel/preset-env']
21+
}
22+
}
23+
},
24+
{ test: /\.mdx?$/, use: ['babel-loader', '@mdx-js/loader'] }
25+
]
26+
},
27+
plugins: [
28+
new HtmlWebpackPlugin({
29+
template: `./index.html`
30+
})
31+
]
32+
};

0 commit comments

Comments
 (0)