-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
executable file
·74 lines (73 loc) · 1.95 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
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LiveReloadPlugin = require('webpack-livereload-plugin');
const postcssUrl = require('postcss-url');
const postcssImport = require('postcss-import');
const postcssCssnext = require('postcss-cssnext');
const postcssReporter = require('postcss-reporter');
module.exports = {
entry: {
app: './src/index'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
publicPath: '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new LiveReloadPlugin({ port: 35831, appendScriptTag: true }),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('[name].css', { allChunks: true }),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.template.html'
})
],
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss')
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!less')
},
{
test: /\.js$/,
loaders: ['babel'],
exclude: /(node_modules|bower_components)/
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?digest=hex&name=[name].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.(ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file?name=fonts/[name]-[hash].[ext]'
},
{
test: /\.(wav|mp3)$/i,
loader: 'file?name=[name]-bundle-[hash].[ext]'
},
{
test: /\.json$/,
loader: 'json'
}
]
},
postcss: (wp) => {
return [
postcssImport({ addDependencyTo: wp }),
postcssUrl(),
postcssCssnext(),
postcssReporter()
];
}
};