7

Adds front-end tooling

This commit is contained in:
Jasper Berghoef
2017-05-23 14:26:36 +02:00
committed by Boris Besemer
parent 7fda6f411a
commit 2cff8a01fe
31 changed files with 6315 additions and 255 deletions

95
webpack.config.js Normal file
View File

@ -0,0 +1,95 @@
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
module.exports = {
context: path.resolve(__dirname, './frontend'),
entry: {
index: './js/index.js',
form: './js/form.js'
},
output: {
path: path.resolve(__dirname, './src/personalisation/static/js'),
filename: '[name].js',
sourceMapFilename: '[file].map'
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: { presets: ['react', 'es2015', 'stage-0'] }
}]
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: "css-loader",
options: {
sourceMap: true,
minimize: true
}
},
{
loader: "postcss-loader",
options: {
sourceMap: true,
plugins: [ autoprefixer ]
}
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
}
]
})
},
{
test: /\.(png|jpg|jpeg|gif)/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '../img/'
}
}
]
},
resolve: {
extensions: [ '.js', '.jsx' ],
modules: [ 'node_modules' ]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'commons',
filename: 'commons.js',
minChunks: 2
}),
new CopyWebpackPlugin([
{
from: './img',
to: '../img'
}
]),
new ImageminPlugin(),
new ExtractTextPlugin({
filename: '../css/[name].css',
allChunks: true
})
]
};