forked from SouthAmericansSecrets/web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
91 lines (89 loc) · 2.5 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
var webpack = require('webpack'),
path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
NunjucksWebpackPlugin = require('nunjucks-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
fs = require('fs');
/* babel */
const babelSettings = JSON.parse(fs.readFileSync(".babelrc"));
/* read templates */
var templates = fs.readdirSync(path.resolve(__dirname, 'app/tpl/pages/'));
var tpls=[];
for (var i = 0; i < templates.length; i++) {
file = templates[i];
templateName = file.split('.')[0];
tpls.push({from: path.resolve(__dirname, 'app/tpl/pages/'+file),to:templateName+'.html'});
}
module.exports = {
entry: {
templates:'./app/templates.js',
index: './app/scripts/index.js',
tours:'./app/scripts/tours.js',
activities:'./app/scripts/activities.js',
menu:'./app/scripts/menu.js',
contact: './app/scripts/contact.js',
package: './app/scripts/package.js',
article: './app/scripts/article.js',
articledetail: './app/scripts/article-detail.js',
footer: './app/scripts/footer.js',
firebase: './app/scripts/firebase.js',
backoffice: './app/scripts/backoffice.js',
messageboard: './app/scripts/messageboard.js',
about: './app/scripts/about.js',
messageboard_settings: './app/scripts/messageboard-settings.js',
reservations: './app/scripts/reservations.js',
splash: './app/scripts/splash-ad.js',
cruises: './app/scripts/cruises.js'
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js'
},
resolve: {
extensions: ['.jsx', '.js','.njk','.html']
},
devServer: {
contentBase: path.resolve(__dirname, 'public'),
host: '0.0.0.0',
port: 9000,
inline: true
},
module: {
loaders: [
{
test: /(\.js|.jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: babelSettings
},
{
test: /(\.njk|.nunjucks)$/,
loader: 'nunjucks-loader',
query: {
root: __dirname + '/app/tpl'
}
},
]
},
externals: {
"jquery": "jQuery"
},
plugins: [
new NunjucksWebpackPlugin({template: tpls}),
new CopyWebpackPlugin([
{from: 'public/css', to: 'css'},
{from: 'public/videos', to: 'videos'},
{from: 'public/js', to: 'js'},
{from: 'public/images', to: 'images'},
{from: 'public/fonts', to: 'fonts'},
{from: 'public/manifest.json', to: 'manifest.json'},
{from: 'public/*.html', to: '/'},
{
context: 'public',
from: '**/*',
to: '/'
},
])
],
devtool: "source-map"
};