From f020f4397c1929d20ccf4e2c98715eee686bcefb Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 25 Sep 2015 11:43:28 +0100 Subject: [PATCH] Switch to webpack Webapck actually supports loading input source maps and generally seems a lot more solid then browserify (even if their website has an annoying animated logo). --- .gitignore | 4 ++-- package.json | 19 ++++++++++++------- {vector => src/vector}/index.js | 2 +- webpack.config.js | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) rename {vector => src/vector}/index.js (98%) create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index a88579880c..13466ce843 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules -bundle.css -bundle.js +vector/bundle.* +lib diff --git a/package.json b/package.json index 1a2f8118dd..24c1849eeb 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,15 @@ "style": "bundle.css", "scripts": { "reskindex": "reskindex vector -h src/skins/vector/header", - "build": "NODE_ENV=production browserify --ignore olm -t reactify vector/index.js | uglifyjs -c -m -o vector/bundle.js", - "start": "parallelshell 'watchify --ignore olm -v -d -t reactify vector/index.js -o vector/bundle.js' 'npm run start:skins:css' 'http-server vector'", - "build:skins:js": "babel src/skins -d lib/skins --source-maps", - "build:skins:css": "catw 'src/skins/vector/css/**/*.css' -o vector/bundle.css -c uglifycss --no-watch", + "build:css": "catw 'src/skins/vector/css/**/*.css' -o vector/bundle.css -c uglifycss --no-watch", + "build:compile": "babel --source-maps -d lib src", + "build:bundle": "NODE_ENV=production webpack -p lib/vector/index.js vector/bundle.js", + "build": "npm run build:css && npm run build:compile && npm run build:bundle", + "start:js": "webpack -w src/vector/index.js vector/bundle.js", "start:skins:css": "catw 'src/skins/vector/css/**/*.css' -o vector/bundle.css", - "clean": "rimraf lib vector/bundle.css vector/bundle.js", - "prepublish": "npm run build:skins" + "start": "parallelshell 'npm run start:js' 'npm run start:skins:css' 'http-server vector'", + "clean": "rimraf lib vector/bundle.css vector/bundle.js vector/bundle.js.map vector/bundle.webpack.js vector/bundle.webpack.js.map", + "prepublish": "npm run build:css && npm run build:compile" }, "dependencies": { "matrix-react-sdk": "^0.0.1", @@ -31,10 +33,13 @@ }, "devDependencies": { "babel": "^5.8.23", + "babel-core": "^5.8.25", + "babel-loader": "^5.3.2", "catw": "^1.0.1", + "http-server": "^0.8.4", "parallelshell": "^1.2.0", - "react-tools": "^0.13.3", "rimraf": "^2.4.3", + "source-map-loader": "^0.1.5", "uglifycss": "0.0.15" } } diff --git a/vector/index.js b/src/vector/index.js similarity index 98% rename from vector/index.js rename to src/vector/index.js index 9eaecc08ac..accba178ad 100644 --- a/vector/index.js +++ b/src/vector/index.js @@ -18,7 +18,7 @@ limitations under the License. var React = require("react"); var sdk = require("matrix-react-sdk"); -sdk.loadSkin(require('../src/skins/vector/skindex')); +sdk.loadSkin(require('../skins/vector/skindex')); var lastLocationHashSet = null; diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000000..6e557ae635 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,25 @@ +var path = require('path'); +var webpack = require('webpack'); + +module.exports = { + module: { + preLoaders: [ + { test: /\.js$/, loader: "source-map-loader" } + ], + loaders: [ + { test: /\.json$/, loader: "json" }, + { test: /\.js$/, loader: "babel", include: path.resolve('./src') }, + ] + }, + resolve: { + alias: { + // alias any requires to the react module to the one in our path, otherwise + // we tend to get the react source included twice when using npm link. + react: path.resolve('./node_modules/react'), + }, + }, + plugins: [ + new webpack.IgnorePlugin(/^olm/) + ], + devtool: 'source-map' +};