Commit acdfa942 authored by G.Tjebbes's avatar G.Tjebbes

Add js webpack base stuff + update Makefile

parent 68376483
JS_SOURCES_DIR=js_sources/
JS_TEMPLATE_MAIN_FILE=autonomie/static/js/template.js
JS_TEMPLATE_DEST=autonomie/static/js/templates
JS_TEMPLATES_SOURCE=handlebars
JS_TEMPLATES_SOURCE=$(JS_SOURCES_DIR)src/handlebars
DIRECTORIES=$(shell cd $(JS_TEMPLATES_SOURCE) && find * -maxdepth 1 -type d)
SASSC=$(shell which sassc)
CSS_SOURCES=css_sources/main.scss
CSS_DEST=autonomie/static/css/main.css
# Used to build templates used in inline javascript stuff (not webpacked)
js:
handlebars $(JS_TEMPLATES_SOURCE)/*.mustache -f $(JS_TEMPLATE_MAIN_FILE)
for dir in $(DIRECTORIES);do \
handlebars $(JS_TEMPLATES_SOURCE)/$$dir/*.mustache -f $(JS_TEMPLATE_DEST)/$$dir.js; \
done
# build js with webpack
prodjs:
cd $(JS_SOURCES_DIR) && npm run prod
devjs:
cd $(JS_SOURCES_DIR) && npm run dev
# build css with libsassc
css:
$(SASSC) $(CSS_SOURCES) $(CSS_DEST)
......
{
"presets" : ["es2015"]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "Autonomie",
"description": "Some Autonomie frontend stuffDescription",
"author": "Gaston Tjebbes @ Majerti",
"version": "3.3.3",
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"dev": "export NODE_ENV=dev && webpack -d --watch",
"prod": "export NODE_ENV=production && webpack -p"
},
"dependencies": {
"backbone": "^1.3.3",
"backbone-validation": "^0.11.5",
"backbone.marionette": "^3.3.1",
"backbone.radio": "^2.0.0",
"jquery": "^3.2.1",
"jquery-ui": "^1.12.1",
"pickadate": "^3.5.6"
},
"devDependencies": {
"babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"copy-webpack-plugin": "^1.1.1",
"css-loader": "^0.23.1",
"eslint": "^2.11.1",
"extract-text-webpack-plugin": "^1.0.1",
"stylus": "^0.54.5",
"style-loader": "^0.13.1",
"webpack": "^1.12.15",
"webpack-dev-server": "^1.16.2",
"webpack-merge": "^0.15.0",
"handlebars": "^2.0.0",
"handlebars-loader": "*"
}
}
'use strict';
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const merge = require('webpack-merge');
const APP_DIR = path.resolve(__dirname, 'src');
const BUILD_DIR = path.resolve(__dirname, "..", "autonomie/static/js/build/");
var PROD = (process.env.NODE_ENV === 'production');
const config = {
entry: {
task: path.join(APP_DIR, 'task', 'task.js')
},
module: {
loaders: [
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015']
}
},
{
test: /\.mustache$/,
loader: "handlebars-loader"
}
]
},
output: {
path: BUILD_DIR,
filename: PROD ? '[name].min.js': '[name].js'
},
plugins: PROD? [
new webpack.ProvidePlugin({
$: 'jquery',
_: 'underscore'
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]: [
new webpack.ProvidePlugin({
$: 'jquery',
_: 'underscore'
})
],
resolve: {
root: path.join(__dirname, './src')
},
resolveLoader: {
root: path.join(__dirname, './node_modules')
}
};
module.exports = config;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment