Skip to content

Commit b2464e8

Browse files
committed
module 7 bundling
1 parent de54d97 commit b2464e8

File tree

6 files changed

+53
-2
lines changed

6 files changed

+53
-2
lines changed

buildScripts/srcServer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import express from 'express';
22
import path from 'path';
33
import open from 'open';
4+
import webpack from 'webpack';
5+
import config from '../webpack.config.dev';
46

57
const port = 3000;
68
const app = express();
9+
const compiler = webpack(config);
10+
11+
app.use(require('webpack-dev-middleware')(compiler, {
12+
noInfo: true,
13+
publicPath: config.output.publicPath
14+
}));
715

816
app.get('/', function(req, res) {
917
res.sendFile(path.join(__dirname, '../src/index.html'));

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
},
1313
"author": "Cory House",
1414
"license": "MIT",
15-
"dependencies": {
16-
},
15+
"dependencies": {},
1716
"devDependencies": {
1817
"babel-cli": "6.14.0",
1918
"babel-core": "6.14.0",
@@ -24,6 +23,7 @@
2423
"chalk": "1.1.3",
2524
"cheerio": "0.22.0",
2625
"cross-env": "2.0.0",
26+
"css-loader": "^0.25.0",
2727
"eslint": "3.4.0",
2828
"eslint-plugin-import": "1.14.0",
2929
"eslint-watch": "2.1.14",
@@ -38,6 +38,7 @@
3838
"numeral": "1.5.3",
3939
"open": "0.0.5",
4040
"rimraf": "2.5.4",
41+
"style-loader": "^0.13.1",
4142
"webpack": "1.13.2",
4243
"webpack-dev-middleware": "1.6.1",
4344
"webpack-hot-middleware": "2.12.2",

src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
font-family: Sans-Serif;
3+
}
4+
5+
table th {
6+
padding: 5px
7+
}

src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
</head>
66
<body>
77
<h1>Hello World!</h1>
8+
<script src="bundle.js"></script>
89
</body>
910
</html>

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import './index.css';
2+
3+
import numeral from 'numeral';
4+
5+
const courseValue = numeral(1000).format('$0,0.00');
6+
debugger;
7+
console.log(`I would pay ${courseValue} for this awesome course!`);

webpack.config.dev.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import webpack from 'webpack';
2+
import path from 'path';
3+
4+
export default {
5+
debug: true,
6+
devtool: 'inline-source-map',
7+
noInfo: false,
8+
entry: [
9+
path.resolve(__dirname, 'src/index')
10+
],
11+
target: 'web',
12+
output: {
13+
path: path.resolve(__dirname, 'src'),
14+
publicPath: '/',
15+
filename: 'bundle.js'
16+
},
17+
devServer: {
18+
contentBase: path.resolve(__dirname, 'src')
19+
},
20+
plugins: [],
21+
module: {
22+
loaders: [
23+
{test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},
24+
{test: /\.css$/, loaders: ['style','css']}
25+
]
26+
}
27+
};

0 commit comments

Comments
 (0)