-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.babel.js
103 lines (92 loc) · 2.57 KB
/
webpack.config.babel.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
99
100
101
102
103
import webpack from "webpack";
import path from "path";
import HtmlWebpackPlugin from "html-webpack-plugin";
import ExtractTextPlugin from "extract-text-webpack-plugin";
import CopyWebpackPlugin from 'copy-webpack-plugin';
import autoprefixer from "autoprefixer";
import {basic} from "./jld.js";
var plugins = [
new ExtractTextPlugin("[name].[hash].css", {disable: process.env.NODE_ENV !== 'production'}), // Disable extract-text-plugin during development for hot-reloading CSS.
new HtmlWebpackPlugin({
title: "#CivicTechFest",
jld: basic,
description: "Asia’s first ever civic technology festival and conference is coming on 2017 Sep. 10th - 16th at Taipei, Taiwan. ",
filename: "index.html",
template: "app/templates/index.html"
}),
new CopyWebpackPlugin([
{from: "app/javascripts/pages/**/*.png", to: "images/", flatten: true},
]),
];
if (/production/.test(process.env.NODE_ENV)) {
plugins = plugins.concat([
new webpack.optimize.UglifyJsPlugin()
]);
}
export default {
entry: {
application: "./app/javascripts/application.js",
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].[hash].js",
publicPath: "/",
},
resolve: {
extensions: ["", ".js", ".jsx", ".css"],
modulesDirectories: ["app", "node_modules"],
},
module: {
loaders: [
{
test: /\.(png|jpg|svg|jpeg|PNG|JPG|SVG|JPEG)$/,
loader: 'url?limit=10000',
exclude: /sponsors|og\.png$/, // Facebook can't recognize inline og:image.
},
{
test: /app\/images\/keynote/,
loader: 'file',
query: {
name: "images/keynote/[name].[ext]"
}
},
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel',
},
{
test: /app\/fonts\//,
loader: 'file',
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&localIdentName=[name]-[local]__[hash:base64:5]&importLoaders=1&sourceMap!postcss')
},
{
test: /\.json$/,
loader: 'json',
},
{
test: /\.md$/,
loader: 'html!markdown',
},
{
test: /template.html$/,
loader: 'raw-loader',
},
]
},
postcss: [
require('lost'),
require('precss'),
autoprefixer({ browsers: ['last 2 versions', '> 1%', 'Firefox > 20'] }),
],
devServer: {
host: process.env.HOST || 'localhost',
contentBase: path.join(__dirname, "dist"),
publicPath: '/',
historyApiFallback: {index: '/'},
},
plugins,
};