Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 3b6d901

Browse files
committed
feat(content) initial release
1 parent b771f07 commit 3b6d901

File tree

2 files changed

+4
-81
lines changed

2 files changed

+4
-81
lines changed

Diff for: gulpfile.js

+3-24
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
var gulp = require('gulp'),
1010
sync = require('run-sequence'),
1111
serve = require('browser-sync'),
12-
/* START SOLUTION */
13-
webpack = require('gulp-webpack');
14-
/* END SOLUTION */
1512

1613
/*
1714
* A convenience object to hold different paths we care about.
@@ -23,26 +20,8 @@ var paths = {
2320
app: ['client/**/*.{js,css,html}']
2421
};
2522

26-
/* START SOLUTION */
27-
/*
28-
* Gulp is built ontop of node's powerful 'stream' concepts.
29-
* You can think of a stream as faucet of water that flows through different 'pipes'
30-
* We open the gulp faucet by passing a glob of files into gulp.src.
31-
* Then we can 'pipe' these files through all sorts of different transformations,
32-
* each one returning its own stream that can continue to be piped into more transformations.
33-
*
34-
* Here, we're grabbing the entry point to our (making the `entry` property in webpack.config.js unnecessary),
35-
* piping the entry into webpack plugin, bundling our app, and piping that into the client folder designated by gulp.dest
36-
*
37-
* NOTE: gulp.dest defines our webpack's output folder. Webpack will get mad if it finds an output.path property
38-
* in webpack.config.js. We still need `filename` though.
39-
*/
40-
gulp.task('build', function() {
41-
return gulp.src('./client/app.js')
42-
.pipe(webpack(require('./webpack.config.js')))
43-
.pipe(gulp.dest('client'));
44-
});
45-
/* END SOLUTION */
23+
// TODO: Write a `gulp build` task that uses webpack to build your app and output it to `client/bundle.js`
24+
// HINT: Some properties that are needed to run `webpack` from the CLI are unnecessary when paired with gulp
4625

4726
/*
4827
* Browsersync manages a server that plays nicely with gulp (see serve.reload below)
@@ -83,5 +62,5 @@ gulp.task('watch', function() {
8362
* and then invoke the `done` callback to let gulp know all asyncronous tasks have been completed.
8463
*/
8564
gulp.task('default', function(done) {
86-
sync(/*START SOLUTION*/'build'/*END SOLUTION*/, 'serve', 'watch', done);
65+
sync('serve', 'watch', done);
8766
});

Diff for: webpack.config.js

+1-57
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* START SOLUTION */
21
/*
32
* This is where we tell Webpack exactly what we want it to do.
43
*
@@ -8,59 +7,4 @@
87
* 3) What we want to do with the files in our app (module.loaders)
98
*/
109

11-
module.exports = {
12-
/*
13-
* Organizing our code in modules is a bit different than the traditional style.
14-
* Gone are the days of endless <script> tags in index.html that must be carefully ordered.
15-
* Instead, our `entry` point defines where our app starts. It's here where we'll import
16-
* all other files as needed, and Webpack manages the tree of dependencies automagically.
17-
*
18-
* If you've ever used node, your app's entry point is conventionally `index.js`
19-
*/
20-
// entry: './client/app.js', (unnecessary with gulp - gulp.src does this for us)
21-
22-
/*
23-
* Not only will Webpack gracefully manage the tree of dependencies for us, it can also
24-
* smash all the dependencies into one convenient file that we can send over the wire.
25-
* This is similar to minification. The `output` object defines where this minified file should live
26-
*/
27-
output: {
28-
// path: __dirname + '/client', // Absolute (!) path for our output file (unnecessary with gulp - gulp.dest does this for us)
29-
filename: 'bundle.js', // `bundle.js` is a typical convention for Webpack
30-
},
31-
32-
/*
33-
* Bundles are all fun and games until you have to debug them. It's not easy
34-
* sorting through one giant file of transpiled ES5 code to see where you went wrong.
35-
*
36-
* Sourcemaps are an invaluable tool when debugging. They map your bundle to your
37-
* source files and allow you to trace errors in your bundle back to the code you
38-
* actually wrote. You should always use source maps when developing with a transpiler.
39-
*/
40-
devtool: 'sourcemap', // Will be created at './client/app/bundle.js.map'
41-
42-
/*
43-
* This is where most of magic happens. Webpack loaders allow you to preprocess files as you import them.
44-
* They are kind of like 'tasks' in other build tools. In fact, if you are using another build tool
45-
* like gulp or grunt along with Webpack, you should leave any task that touch files
46-
* (transpilation, minification, etc) to Webpack and use your other build system to orchastrate other automation.
47-
*
48-
* Loaders can tranform files from a different language (TypeScript to JavaScript or ES6 to ES5!)
49-
* Loaders even allow you to do things like import css files right in your JavaScript!
50-
51-
* Each loader is just an object that defines (1) a collection of files (2) the transformation.
52-
* Here's how the properties work:
53-
* test: A condition that must be met (regex)
54-
* loader: A string of "!" separated loaders (these are executed from right to left)
55-
* include: A condition that must be met (not included, but reges)
56-
* exclude: A condition that must not be met (regex)
57-
*/
58-
module: {
59-
loaders: [
60-
{ test: /\.js$/, loader: 'babel', exclude: [/node_modules/]}, // Transpile our .js from ES6 to ES5
61-
{ test: /\.html$/, loader: 'raw' }, // 'raw' will import our html as a string - great for Angular templates!
62-
{ test: /\.css$/, loader: 'style!css' } // 'css' loader will parse our stylesheets, and 'style' loader will inject it into the <head> of our index.html
63-
]
64-
}
65-
};
66-
/* END SOLUTION */
10+
module.exports = {};

0 commit comments

Comments
 (0)