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).
This commit is contained in:
David Baker 2015-09-25 11:43:28 +01:00
parent bfa4cda2c6
commit f020f4397c
4 changed files with 40 additions and 10 deletions

4
.gitignore vendored
View file

@ -1,3 +1,3 @@
node_modules
bundle.css
bundle.js
vector/bundle.*
lib

View file

@ -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"
}
}

View file

@ -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;

25
webpack.config.js Normal file
View file

@ -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'
};