forked from benjajaja/edice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
107 lines (99 loc) · 2.56 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
105
106
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: [
'./html/elm-dice.js',
'./html/index.html',
'./html/elm-dice.css',
//'./html/elm-dice-serviceworker.js',
],
output: {
path: path.join(__dirname, './dist'),
filename: 'elm-dice.js'
},
resolve: {
modules: [
'node_modules',
path.join(__dirname, "src"),
],
extensions: ['.js', '.elm']
},
module: {
rules: [
{
test: /\.(html|woff2|png|xml|ico|svg|json)$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
context: 'html',
name: '[path][name].[ext]',
},
},
],
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: [ 'elm-webpack-loader' ],
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader', options: { importLoaders: 1 } },
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: function(loader) {
return [
require('autoprefixer')({ browsers: ['last 10 versions'] }),
require('postcss-partial-import')({
addDependencyTo: webpack,
prefix: '',
extension: '',
}),
];
},
},
},
],
}),
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new ExtractTextPlugin("elm-dice.css"),
new CopyWebpackPlugin([
{ from: 'html/manifest.json' },
{ from: 'html/favicons', to: 'favicons'},
{ from: 'html/favicon.ico' },
{ from: 'html/die.svg' },
{ from: 'html/elm-dice-serviceworker.js' },
{ from: 'html/cache-polyfill.js' },
{ from: 'html/sounds', to: 'sounds'},
]),
].concat(process.env.NODE_ENV === 'production'
? new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
})
: []),
devServer: {
host: '0.0.0.0',
port: 5000,
inline: true,
stats: 'errors-only',
contentBase: './html',
historyApiFallback: true,
disableHostCheck: true,
}
};