-
Notifications
You must be signed in to change notification settings - Fork 189
move to webpack-dev-server; separate webpack configs; add html-webpack-plugin #39
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,14 @@ | |
| "name": "spectacle-boilerplate", | ||
| "version": "1.0.1", | ||
| "description": "ReactJS Powered Presentation Framework", | ||
| "main": "lib/index.js", | ||
| "main": "dist/bundle.js", | ||
| "scripts": { | ||
| "clean": "rimraf dist", | ||
| "prebuild": "npm run clean", | ||
| "build": "cross-env NODE_ENV=production webpack --config webpack.config.production.js", | ||
| "clean": "rimraf dist", | ||
| "lint": "eslint --ext .js,.jsx .", | ||
| "deploy": "npm run clean & npm run build && surge -p .", | ||
| "start": "cross-env NODE_ENV=development node server.js" | ||
| "deploy": "npm run clean & npm run build && surge -p dist", | ||
| "start": "cross-env NODE_ENV=development webpack-dev-server --hot --port 3000 --content-base dist --config webpack.config.development.js" | ||
| }, | ||
| "author": "", | ||
| "license": "MIT", | ||
|
|
@@ -44,19 +45,22 @@ | |
| "express": "^4.13.3", | ||
| "file-loader": "^0.9.0", | ||
| "html-loader": "^0.4.0", | ||
| "html-webpack-plugin": "~2.28.0", | ||
| "is-buffer": "^1.1.1", | ||
| "markdown-loader": "^0.1.7", | ||
| "node-libs-browser": "^0.5.3", | ||
| "object-assign": "~4.1.1", | ||
| "raw-loader": "^0.5.1", | ||
| "react-transform-catch-errors": "^1.0.0", | ||
| "react-transform-hmr": "^1.0.4", | ||
| "redbox-react": "^1.2.0", | ||
| "raw-loader": "^0.5.1", | ||
| "rimraf": "^2.4.4", | ||
| "style-loader": "^0.13.0", | ||
| "surge": "latest", | ||
| "url-loader": "^0.5.6", | ||
| "webpack": "2.2.0", | ||
| "webpack": "~2.4.1", | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bumped the webpack version |
||
| "webpack-dev-middleware": "^1.8.4", | ||
| "webpack-dev-server": "~2.4.5", | ||
| "webpack-hot-middleware": "^2.13.0" | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* eslint-disable */ | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could improve this whole file by switching to webpack-merge or the like, but didn't want to get too crazy off of the bat |
||
| var path = require("path"); | ||
| var webpack = require("webpack"); | ||
| var assign = require("object-assign"); | ||
|
|
||
| var config = require("./webpack.config"); | ||
|
|
||
| config.devtool = 'cheap-module-eval-source-map'; | ||
|
|
||
| config.output = assign(config.output, { | ||
| publicPath: "/" | ||
| }); | ||
|
|
||
| config.plugins = config.plugins.concat([ | ||
| new webpack.NoEmitOnErrorsPlugin() | ||
| ]); | ||
|
|
||
| config.module.rules[0] = { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't like that this requires the first item to always be the |
||
| test: /\.(js|jsx)$/, | ||
| exclude: /node_modules/, | ||
| loader: "babel-loader", | ||
| query: { | ||
| plugins: [ | ||
| [ | ||
| "react-transform", { | ||
| transforms: [{ | ||
| transform: "react-transform-hmr", | ||
| imports: ["react"], | ||
| locals: ["module"] | ||
| }, { | ||
| transform: "react-transform-catch-errors", | ||
| imports: ["react", "redbox-react"] | ||
| }] | ||
| } | ||
| ] | ||
| ] | ||
| }, | ||
| exclude: /node_modules/, | ||
| include: __dirname | ||
| }; | ||
|
|
||
| module.exports = config; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,69 +2,52 @@ | |
|
|
||
| var path = require("path"); | ||
| var webpack = require("webpack"); | ||
| var HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
|
|
||
| module.exports = { | ||
| devtool: "source-map", | ||
| entry: [ | ||
| "webpack-hot-middleware/client", | ||
| "babel-polyfill", | ||
| "./index" | ||
| "./src/index" | ||
| ], | ||
| output: { | ||
| path: path.join(__dirname, "dist"), | ||
| filename: "bundle.js", | ||
| publicPath: "/dist/" | ||
| publicPath: "./" | ||
| }, | ||
| plugins: [ | ||
| new webpack.HotModuleReplacementPlugin(), | ||
| new webpack.NoEmitOnErrorsPlugin() | ||
| new webpack.DefinePlugin({ | ||
| "process.env": { | ||
| "NODE_ENV": JSON.stringify(process.env.NODE_ENV) | ||
| } | ||
| }), | ||
| new HtmlWebpackPlugin({ | ||
| template: path.join(__dirname, "public/index.html") | ||
| }) | ||
| ], | ||
| resolve: { | ||
| alias: { | ||
| assets: path.join(__dirname, "assets") | ||
| } | ||
| }, | ||
| module: { | ||
| loaders: [{ | ||
| test: /\.md$/, | ||
| loader: "html-loader!markdown-loader?gfm=false" | ||
| }, { | ||
| rules: [{ | ||
| test: /\.(js|jsx)$/, | ||
| exclude: /node_modules/, | ||
| loader: "babel-loader", | ||
| query: { | ||
| plugins: [ | ||
| [ | ||
| "react-transform", { | ||
| transforms: [{ | ||
| transform: "react-transform-hmr", | ||
| imports: ["react"], | ||
| locals: ["module"] | ||
| }, { | ||
| transform: "react-transform-catch-errors", | ||
| imports: ["react", "redbox-react"] | ||
| }] | ||
| } | ||
| ] | ||
| ] | ||
| }, | ||
| exclude: /node_modules/, | ||
| include: __dirname | ||
| loader: "babel-loader" | ||
| }, { | ||
| test: /\.css$/, | ||
| loaders: ["style-loader", "raw-loader"], | ||
| loaders: ["style-loader", "css-loader"], | ||
| include: __dirname | ||
| }, { | ||
| test: /\.svg$/, | ||
| loader: "url-loader?limit=10000&mimetype=image/svg+xml", | ||
| include: path.join(__dirname, "assets") | ||
| }, { | ||
| test: /\.png$/, | ||
| loader: "url-loader?mimetype=image/png", | ||
| include: path.join(__dirname, "assets") | ||
| test: /\.md$/, | ||
| loader: "html-loader!markdown-loader?gfm=false" | ||
| }, { | ||
| test: /\.gif$/, | ||
| loader: "url-loader?mimetype=image/gif", | ||
| include: path.join(__dirname, "assets") | ||
| test: /\.(png|jpe?g|gif)$/, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merged these loaders, not sure if the mimetype was doing a whole bunch. If so, I'll switch it back! |
||
| loader: "url-loader?limit=8192" | ||
| }, { | ||
| test: /\.jpg$/, | ||
| loader: "url-loader?mimetype=image/jpg", | ||
| include: path.join(__dirname, "assets") | ||
| test: /\.svg$/, | ||
| loader: "url-loader?limit=10000&mimetype=image/svg+xml" | ||
| }] | ||
| } | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-explanatory, but swap out the custom express server and just use webpack dev server. Hot reloading and everything (to the best of my knowledge/testing) still works!