forked from velafrica/velafrica-django
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
98 lines (95 loc) · 2.61 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* global __dirname, process */
var path = require('path');
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var autoprefixer = require('autoprefixer');
var nodeModulesDir = path.join(__dirname, 'node_modules');
var host = process.env.HOST || '127.0.0.1';
var config = {
context: path.join(__dirname, 'staticfiles'),
debug: true,
entry: {
main: [
'webpack-dev-server/client?http://' + host + ':4000',
'webpack/hot/dev-server',
'./../velafrica/frontend/static/js/main.js',
'./../velafrica/frontend/static/scss/main.scss',
],
},
output: {
path: path.resolve('./staticfiles/dist/'),
publicPath: 'http://' + host + ':4000/assets/build/',
filename: '[name]-[hash].js',
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
'babel?presets[]=es2015,cacheDirectory=' + path.resolve(__dirname, 'tmp'),
],
},
{
test: /\.css$/,
loader: 'style!css',
},
// Optionally extract less files
// or any other compile-to-css language
{
test: /\.scss$/,
loader: 'style!css!postcss!sass',
},
{
test: /\.less/,
loader: 'style-loader!css-loader!less-loader?relative-urls',
},
{
test: /\.(png|woff2?|svg|eot|ttf)$/,
loader: 'url-loader?limit=20000',
},
{
test: /\.(jpg)$/,
loader: 'file?relative-urls',
},
],
noParse: [],
},
postcss: [
autoprefixer({
browsers: ['last 3 versions', 'ie >= 9', 'safari >= 6', 'chrome >= 49', 'firefox >= 44'],
}),
],
sassLoader: {
includePaths: [path.resolve(nodeModulesDir)],
outputStyle: 'expanded',
sourceMap: true,
},
resolve: {
// Allow require('./blah') to require blah.jsx
extensions: ['', '.js', '.jsx'],
modulesDirectories: [
'assets/js',
'assets/scss',
'assets/img',
'node_modules',
'static/js',
'static/bootstrap-3.3.6-dist/js',
],
alias: {},
},
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(), // don't reload if there is an error
new BundleTracker({filename: './tmp/webpack-stats.json'}),
],
// dev server not working yet. Have to not extract css during development.
// devServer: {
// contentBase: path.join(__dirname, 'app', 'static', 'app', 'build', 'dist'),
// inline: true,
// colors: true,
// quiet: false,
// },
};
module.exports = config;