diff --git a/.gitignore b/.gitignore index cde1e9f..cdc9c74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ node_modules -jam assets -records.json \ No newline at end of file +npm-debug.log \ No newline at end of file diff --git a/README.md b/README.md index f3e9cf3..6bec634 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,15 @@ # webpack webapp example -For demonstration this app uses `npm` and `jam` package manager. +For demonstration this app uses `npm` package manager. Install and build this app with: ``` text # You need to have node.js installed -npm install jamjs@0.2.x webpack@1.2.x webpack-dev-server@1.2.x -g +npm install cd example-app npm install -jam install webpack -p --progress --colors --devtool sourcemap --hot webpack -p --progress --colors --devtool sourcemap --hot --config webpack-update1.config.js @@ -18,8 +17,6 @@ webpack -p --progress --colors --devtool sourcemap --hot --config webpack-update index.html ``` -NOTE: It's a production ready build, so it may take a while. - For watching and debugging you can alternatively compile with: ``` text diff --git a/app/app.js b/app/app.js index 1d05df8..86401e2 100644 --- a/app/app.js +++ b/app/app.js @@ -1,8 +1,8 @@ var $ = require("jquery"); require("./style.css"); -var body = require("./body.jade")(); -require("bundle!./sources.jade")(function(sources) { +var body = require("./body.pug")(); +require("bundle-loader!./sources.pug")(function(sources) { $(function() { $("#choosen-sources").html(sources()); }); @@ -46,7 +46,7 @@ function loading(name) { isLoading = true; $(".buttons").parent().removeClass("active"); $(".button-"+name).parent().addClass("active"); - $(".content").html(require("./loading.jade")); + $(".content").html(require("./loading.pug")); } function finished() { @@ -100,7 +100,7 @@ window.webpackJsonp = function(chunk, modules) { if(list.length === 0) return; var chunk = list.shift(); var li = $("
  • ") - .html(require("./chunk.jade") + .html(require("./chunk.pug") ({chunk: chunk})); $(".chunks").append(li); append(); diff --git a/app/body.jade b/app/body.pug similarity index 91% rename from app/body.jade rename to app/body.pug index dd5a1c3..12df2fd 100644 --- a/app/body.jade +++ b/app/body.pug @@ -33,13 +33,13 @@ nav.navbar.navbar-default.navbar-top b | webpack on github h2 Choosen sources - #choosen-sources!= require("./loading.jade")() + #choosen-sources!= require("./loading.pug")() .col-md-4 .page-header h1 status small loaded chunks ul.chunks - li!= require("./chunk.jade")({chunk: 0}) + li!= require("./chunk.pug")({chunk: 0}) if module.hot .page-header h1 HMR diff --git a/app/chunk.jade b/app/chunk.pug similarity index 100% rename from app/chunk.jade rename to app/chunk.pug diff --git a/app/home.jade b/app/home.jade deleted file mode 100644 index 6eeaaea..0000000 --- a/app/home.jade +++ /dev/null @@ -1,3 +0,0 @@ -.alert.alert-success You are on Home -h2 home.jade -pre: code= require("!raw!./home.jade") \ No newline at end of file diff --git a/app/home.pug b/app/home.pug new file mode 100644 index 0000000..23fe694 --- /dev/null +++ b/app/home.pug @@ -0,0 +1,3 @@ +.alert.alert-success You are on Home +h2 home.pug +pre: code= require("!raw-loader!./home.pug") \ No newline at end of file diff --git a/app/loading.jade b/app/loading.pug similarity index 100% rename from app/loading.jade rename to app/loading.pug diff --git a/app/pages.js b/app/pages.js index 16c3b53..1f4f438 100644 --- a/app/pages.js +++ b/app/pages.js @@ -3,7 +3,7 @@ module.exports = { switch(name) { case "home": require([], function() { - callback(require("./home.jade")); + callback(require("./home.pug")); }); break; case "test1": @@ -13,12 +13,12 @@ module.exports = { break; case "test2": require.ensure([], function() { - callback(require("./test2.jade")); + callback(require("./test2.pug")); }, "test2+3"); break; case "test3": require.ensure([], function() { - callback(require("./test3.jade")); + callback(require("./test3.pug")); }, "test2+3"); break; default: callback(null); diff --git a/app/sources.jade b/app/sources.pug similarity index 64% rename from app/sources.jade rename to app/sources.pug index fcfd3ed..12082cb 100644 --- a/app/sources.jade +++ b/app/sources.pug @@ -6,18 +6,18 @@ ul.nav.nav-tabs li a(href="#body", data-toggle="tab") i.icon-leaf - | body.jade + | body.pug li a(href="#sources", data-toggle="tab") i.icon-file - | sources.jade + | sources.pug .tab-content #app.tab-pane.active pre.pre-scrollable - code= require("!raw!./app.js") + code= require("!raw-loader!./app.js") #body.tab-pane pre.pre-scrollable - code= require("!raw!./body.jade") + code= require("!raw-loader!./body.pug") #sources.tab-pane pre.pre-scrollable - code= require("!raw!./sources.jade") + code= require("!raw-loader!./sources.pug") diff --git a/app/style.css b/app/style.css index 4c8df6c..e4ce427 100644 --- a/app/style.css +++ b/app/style.css @@ -1,9 +1,5 @@ body {} ------- + .navbar-default { - background: #FFA !important; -} ------- -.navbar-default { - background: #AFA !important; -} + background: #dedede !important; +} \ No newline at end of file diff --git a/app/test1/content.jade b/app/test1/content.jade deleted file mode 100644 index e27a414..0000000 --- a/app/test1/content.jade +++ /dev/null @@ -1,6 +0,0 @@ -h1 three.js canvas - camera - orthographic example -.three-container -h2 test1/index.js -pre.pre-scrollable: code= require("!raw!./index.js") -h2 test1/content.jade -pre: code= require("!raw!./content.jade") \ No newline at end of file diff --git a/app/test1/content.pug b/app/test1/content.pug new file mode 100644 index 0000000..c9496ea --- /dev/null +++ b/app/test1/content.pug @@ -0,0 +1,6 @@ +h1 three.js canvas - camera - orthographic example +.three-container +h2 test1/index.js +pre.pre-scrollable: code= require("!raw-loader!./index.js") +h2 test1/content.pug +pre: code= require("!raw-loader!./content.pug") \ No newline at end of file diff --git a/app/test1/index.js b/app/test1/index.js index 72511b3..2cf6e41 100644 --- a/app/test1/index.js +++ b/app/test1/index.js @@ -1,9 +1,9 @@ exports.render = function() { - return require("./content.jade")(); + return require("./content.pug")(); }; exports.start = function() { - var THREE = require("three"); + var THREE = require("../../web_modules/three/index.js"); require("jquery"); // three.js canvas - camera - orthographic example diff --git a/app/test2.jade b/app/test2.pug similarity index 53% rename from app/test2.jade rename to app/test2.pug index d031832..4283248 100644 --- a/app/test2.jade +++ b/app/test2.pug @@ -1,14 +1,14 @@ .alert.alert-warning span This is the second test. -h2 test2.jade -pre: code= require("!raw!./test2.jade") ------- +h2 test2.pug +pre: code= require("!raw-loader!./test2.pug") + .alert.alert-warning span This is the second test. (Updated Version 1) -h2 test2.jade -pre: code= require("!raw!./test2.jade") ------- +h2 test2.pug +pre: code= require("!raw-loader!./test2.pug") + .alert.alert-warning span This is the second test. (Updated Version 2) -h2 test2.jade -pre: code= require("!raw!./test2.jade") +h2 test2.pug +pre: code= require("!raw-loader!./test2.pug") \ No newline at end of file diff --git a/app/test3.jade b/app/test3.pug similarity index 87% rename from app/test3.jade rename to app/test3.pug index 44ecb83..f358fef 100644 --- a/app/test3.jade +++ b/app/test3.pug @@ -3,13 +3,13 @@ = " " b last | test. ------- + .alert.alert-error | This is the = " " i last | test. (Updated Version 1) ------- + .alert.alert-error | This is the = " " diff --git a/fake-update.js b/fake-update.js deleted file mode 100644 index 8f2e96e..0000000 --- a/fake-update.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = function(content) { - var version = this.options.fakeUpdateVersion; - var versions = content.split("\n------"); - var current = ""; - while(!current) { - current = versions[version--]; - if(current) current = current.replace(/^[\r\n]*|[\r\n]*$/g, ""); - } - this.cacheable(); - return current; -} \ No newline at end of file diff --git a/package.json b/package.json index aff07df..9b00074 100644 --- a/package.json +++ b/package.json @@ -1,41 +1,37 @@ -{ - "name": "example-app", - "version": "0.11.0", - "author": "Tobias Koppers @sokra", - "description": "example web app for webpack", - "dependencies": { - "webpack": "1.2.x", - "webpack-dev-server": "1.3.x", - "bootstrap": "https://github.com/twbs/bootstrap/archive/v3.0.2.tar.gz", - "jade-loader": "0.6.x", - "json-loader": "0.5.x", - "url-loader": "0.5.x", - "file-loader": "0.5.x", - "coffee-loader": "0.7.x", - "jshint-loader": "0.6.x", - "bundle-loader": "0.5.x", - "style-loader": "0.6.x", - "css-loader": "0.6.x", - "less-loader": "0.7.x", - "exports-loader": "0.6.x", - "raw-loader": "0.5.x" - }, - "jam": { - "dependencies": { - "jquery": "1.9.1" - } - }, - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/mit-license.php" - } - ], - "scripts": { - "start": "webpack-dev-server -d --colors" - }, - "engines": { - "node": ">=0.1.30" - }, - "homepage": "http://github.com/webpack/webpack-example" -} \ No newline at end of file +{ + "name": "example-app", + "version": "0.12.0", + "author": "Tobias Koppers @sokra", + "description": "example web app for webpack", + "dependencies": { + "bootstrap": "https://github.com/twbs/bootstrap/archive/v3.0.2.tar.gz", + "bundle-loader": "^0.5.4", + "coffee-loader": "^0.7.2", + "css-loader": "^0.26.1", + "exports-loader": "^0.6.3", + "extract-text-webpack-plugin": "^2.0.0-beta.4", + "file-loader": "^0.9.0", + "jquery": "^3.1.1", + "jshint-loader": "^0.8.3", + "json-loader": "^0.5.4", + "less": "^2.7.1", + "less-loader": "^2.2.3", + "pug": "^2.0.0-beta6", + "pug-loader": "^2.3.0", + "raw-loader": "^0.5.1", + "style-loader": "^0.13.1", + "url-loader": "^0.5.7", + "webpack": "^2.2.0-rc.2", + "webpack-dev-server": "^2.2.0-rc.0" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "scripts": { + "start": "webpack-dev-server -d --colors" + }, + "homepage": "http://github.com/webpack/webpack-example" +} diff --git a/web_modules/mybootstrap/bootstrap.js b/web_modules/mybootstrap/bootstrap.js old mode 100644 new mode 100755 diff --git a/web_modules/mybootstrap/bootstrap.less b/web_modules/mybootstrap/bootstrap.less old mode 100644 new mode 100755 diff --git a/web_modules/mybootstrap/index.js b/web_modules/mybootstrap/index.js old mode 100644 new mode 100755 diff --git a/web_modules/mybootstrap/variables.less b/web_modules/mybootstrap/variables.less old mode 100644 new mode 100755 diff --git a/web_modules/three/index.js b/web_modules/three/index.js index 6026a04..8cbf2d7 100644 --- a/web_modules/three/index.js +++ b/web_modules/three/index.js @@ -1 +1 @@ -module.exports = require("exports?THREE!./Three.min.js"); \ No newline at end of file +module.exports = require("exports-loader?THREE!./Three.min.js"); \ No newline at end of file diff --git a/webpack-update1.config.js b/webpack-update1.config.js index 9f77175..17cf7cf 100644 --- a/webpack-update1.config.js +++ b/webpack-update1.config.js @@ -1,4 +1,2 @@ module.exports = require("./webpack.config.js"); module.exports.output.filename = "ignored"; -module.exports.recordsPath = module.exports.recordsOutputPath; -module.exports.fakeUpdateVersion = 1; diff --git a/webpack-update2.config.js b/webpack-update2.config.js index 5bdfc72..7927d67 100644 --- a/webpack-update2.config.js +++ b/webpack-update2.config.js @@ -1,2 +1 @@ module.exports = require("./webpack-update1.config.js"); -module.exports.fakeUpdateVersion = 2; diff --git a/webpack.config.js b/webpack.config.js index c511e5d..3574298 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,6 @@ var webpack = require("webpack"); var path = require("path"); + module.exports = { context: __dirname, entry: "./app/app.js", @@ -7,47 +8,35 @@ module.exports = { path: path.join(__dirname, "assets"), publicPath: "assets/", // relative path for github pages filename: "main.js", // no hash in main.js because index.html is a static page - chunkFilename: "[hash]/js/[id].js", - hotUpdateMainFilename: "[hash]/update.json", - hotUpdateChunkFilename: "[hash]/js/[id].update.js" + chunkFilename: "[hash]/js/[id].js" }, - recordsOutputPath: path.join(__dirname, "records.json"), module: { - loaders: [ - { test: /\.json$/, loader: "json-loader" }, + rules: [ + { test: /\.json$/, loader: "json-loader" }, { test: /\.coffee$/, loader: "coffee-loader" }, - { test: /\.css$/, loader: "style-loader!css-loader" }, - { test: /\.less$/, loader: "style-loader!css-loader!less-loader" }, - { test: /\.jade$/, loader: "jade-loader?self" }, - { test: /\.png$/, loader: "url-loader?prefix=img/&limit=5000" }, - { test: /\.jpg$/, loader: "url-loader?prefix=img/&limit=5000" }, - { test: /\.gif$/, loader: "url-loader?prefix=img/&limit=5000" }, - { test: /\.woff$/, loader: "url-loader?prefix=font/&limit=5000" }, - { test: /\.eot$/, loader: "file-loader?prefix=font/" }, - { test: /\.ttf$/, loader: "file-loader?prefix=font/" }, - { test: /\.svg$/, loader: "file-loader?prefix=font/" }, + { test: /\.css$/, loader: "style-loader!css-loader" }, + { test: /\.less$/, use: [ + 'style-loader', + 'css-loader', + 'less-loader' + ] + }, + { test: /\.pug$/, loader: "pug-loader" }, + { test: /\.png$/, loader: "url-loader?prefix=img/&limit=5000" }, + { test: /\.jpg$/, loader: "url-loader?prefix=img/&limit=5000" }, + { test: /\.gif$/, loader: "url-loader?prefix=img/&limit=5000" }, + { test: /\.woff$/, loader: "url-loader?prefix=font/&limit=5000" }, + { test: /\.eot$/, loader: "file-loader?prefix=font/" }, + { test: /\.ttf$/, loader: "file-loader?prefix=font/" }, + { test: /\.svg$/, loader: "file-loader?prefix=font/" }, ], - preLoaders: [ - { - test: /\.js$/, - include: pathToRegExp(path.join(__dirname, "app")), - loader: "jshint-loader" - }, - { - // Simulate updates to showcase the hot module replacement - test: pathToRegExp(path.join(__dirname, "app")), - loader: path.join(__dirname, "fake-update.js") - } - ] }, - resolve: { - fallback: path.join(__dirname, "jam") - }, - amd: { jQuery: true }, + resolve: { + alias: { + jquery: "jquery/src/jquery" + } + }, plugins: [ new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 20 }) - ], - fakeUpdateVersion: 0 -}; -function escapeRegExpString(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } -function pathToRegExp(p) { return new RegExp("^" + escapeRegExpString(p)); } \ No newline at end of file + ] +}; \ No newline at end of file