Skip to content

Commit

Permalink
Streamline webpack with all other apps
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 6, 2018
1 parent 650d516 commit a77ce48
Show file tree
Hide file tree
Showing 8 changed files with 4,564 additions and 4,219 deletions.
18 changes: 14 additions & 4 deletions Makefile
Expand Up @@ -5,12 +5,14 @@ build_dir=$(CURDIR)/build
source_dir=$(build_dir)/$(app_name)
sign_dir=$(build_dir)/sign

all: package
all: dev-setup build-js-production

dev-setup: clean npm-update build-js
dev-setup: clean clean-dev npm-init

npm-init:
npm install

npm-update:
rm -rf node_modules
npm update

build-js:
Expand All @@ -19,10 +21,18 @@ build-js:
build-js-production:
npm run build

watch-js:
npm run watch

clean:
rm -f js/notifications.js
rm -f js/notifications.js.map
rm -rf $(build_dir)

package: clean build-js-production
clean-dev:
rm -rf node_modules

package: dev-setup build-js-production
mkdir -p $(source_dir)
rsync -a \
--exclude=/build \
Expand Down
42 changes: 42 additions & 0 deletions js-src/webpack.common.js
@@ -0,0 +1,42 @@
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');

module.exports = {
entry: path.join(__dirname, 'init.js'),
output: {
path: path.resolve(__dirname, '../js'),
publicPath: '/js/',
filename: 'notifications.js'
},
module: {
rules: [
{
test: /\.css$/,
use: ['vue-style-loader', 'css-loader']
},
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
plugins: [new VueLoaderPlugin()],
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
}
};
55 changes: 0 additions & 55 deletions js-src/webpack.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions js-src/webpack.dev.js
@@ -0,0 +1,12 @@
const merge = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
mode: 'development',
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
devtool: '#eval-source-map',
});
7 changes: 7 additions & 0 deletions js-src/webpack.prod.js
@@ -0,0 +1,7 @@
const merge = require('webpack-merge')
const common = require('./webpack.common.js')

module.exports = merge(common, {
mode: 'production',
devtool: '#source-map'
});
2 changes: 1 addition & 1 deletion lib/AppInfo/Application.php
Expand Up @@ -75,7 +75,7 @@ protected function registerUserInterface() {
&& strpos($request->getPathInfo(), '/login/') !== 0
&& substr($request->getScriptName(), 0 - \strlen('/index.php')) === '/index.php') {

Util::addScript('notifications', 'merged');
Util::addScript('notifications', 'notifications');
Util::addStyle('notifications', 'styles');
}
}
Expand Down

0 comments on commit a77ce48

Please sign in to comment.