-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
104 lines (95 loc) · 2.69 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
99
100
101
102
103
104
var webpack = require('webpack')
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require('path');
var env = process.env.MIX_ENV || 'dev';
var prod = env === 'prod';
var plugins = [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
__PROD: prod,
__DEV: env === 'dev'
}),
new CopyWebpackPlugin([{from: "./web/static/assets"}]),
new ExtractTextPlugin("css/styles.css")
];
var devPublicPath = "http://localhost:8080/";
var prodPublicPath = null;
var entry = "./web/static/js/app.js";
var hot = 'webpack-dev-server/client?http://localhost:8080';
var cssProd = {
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract('style-loader', [
'css-loader',
'postcss-loader',
'sass-loader'
],
{
publicPath: "../"
}
)
};
var cssDev = {
test: /\.(css|scss)$/,
loaders: [
'style-loader?root=.',
'css-loader?root=.',
'postcss-loader?root=.',
'sass-loader?root=.'
]
};
var config = {
devtool: prod ? null : 'cheap-module-eval-source-map',
entry: prod ? entry : [hot, entry],
output: {
path: path.resolve(__dirname) + '/priv/static',
filename: "js/app.js",
publicPath: prod ? prodPublicPath : devPublicPath
},
devServer: {
inline: true,
progress: true,
outputPath: "./priv/static"
},
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js', '.elm']
},
module: {
noParse: /\.elm$/,
loaders: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
loader: 'elm-hot!elm-webpack?verbose=true&warn=true'
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]"
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]"
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream&name=fonts/[name].[ext]"
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/application/vnd.ms-fontobject&name=fonts/[name].[ext]"
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml&name=images/[name].[ext]"
},
{
test: /\.png$/,
loader: "url?limit=10000&mimetype=image/png&name=images/[name].[ext]"}
]
},
plugins: prod ? plugins : []
};
if (prod) {
config.module.loaders.push(cssProd);
} else {
config.module.loaders.push(cssDev);
}
module.exports = config;