Skip to content

Commit

Permalink
WebPack? How does that work?
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jan 22, 2018
1 parent 949715b commit 2170692
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ nbproject
.well-known
/.buildpath

# WebPack
/node_modules
/js/merged.js*

# Tests - auto-generated files
/tests/Unit/coverage*
/tests/Unit/clover.xml
Expand Down
3 changes: 3 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* later. See the COPYING file.
*/

import Vue from 'vue';
require('./components/root');

(function(OC, OCA, $, _) {
OCA.Notifications = OCA.Notifications || {};

Expand Down
3 changes: 3 additions & 0 deletions js/components/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* later. See the COPYING file.
*/

require('./action');
require('../richObjectStringParser');

(function(OC, OCA, $) {
OCA.Notifications = OCA.Notifications || {};
OCA.Notifications.Components = OCA.Notifications.Components || {};
Expand Down
2 changes: 2 additions & 0 deletions js/components/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* later. See the COPYING file.
*/

require('./notification');

(function(OC, OCA, $) {
OCA.Notifications = OCA.Notifications || {};
OCA.Notifications.Components = OCA.Notifications.Components || {};
Expand Down
7 changes: 0 additions & 7 deletions js/merged.json

This file was deleted.

66 changes: 66 additions & 0 deletions js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
var path = require('path');
var webpack = require('webpack');

module.exports = {
entry: './js/app.js',
output: {
path: path.resolve(__dirname, '.'),
publicPath: '/',
filename: 'merged.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
performance: {
hints: false
},
devtool: '#eval-source-map'
};

if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map';
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
]);
}
6 changes: 0 additions & 6 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ protected function registerUserInterface() {
&& substr($request->getPathInfo(), 0, strlen('/s/')) !== '/s/'
&& substr($request->getPathInfo(), 0, strlen('/login/')) !== '/login/') {

if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
Util::addScript('notifications', 'vue');
} else {
Util::addScript('notifications', 'vue.min');
}

Util::addScript('notifications', 'merged');
Util::addStyle('notifications', 'styles');
}
Expand Down
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "notifications",
"version": "2.2.0",
"description": "This app provides a backend and frontend for the notification API available in Nextcloud.",
"main": "index.js",
"directories": {
"lib": "lib",
"test": "tests"
},
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --progress --hot --config js/webpack.config.js --watch",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config js/webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nextcloud/notifications.git"
},
"author": "Joas Schilling",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/nextcloud/notifications/issues"
},
"homepage": "https://github.com/nextcloud/notifications#readme",
"dependencies": {
"vue": "^2.5.13"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"cross-env": "^5.1.3",
"css-loader": "^0.28.8",
"file-loader": "^1.1.6",
"vue-hot-reload-api": "^2.2.4",
"vue-loader": "^13.7.0",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.11.0"
}
}

0 comments on commit 2170692

Please sign in to comment.