-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·86 lines (72 loc) · 2.11 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
const path = require('path')
const webpack =require('webpack')
const validate = require('webpack-validator');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
//PostCSS
const postcssImport = require('postcss-import'),
precss = require('precss'),
cssnext = require('postcss-cssnext'),
rucksack = require('rucksack-css');
const PATHS = {
app: path.join(__dirname, './index.js'),
styles: path.join(__dirname, 'src/styles/main.css'),
build: path.join(__dirname, 'public'),
images: path.join(__dirname, 'src/styles/assets')
};
const config = {
//fastest rebuild and build speed
devtool: 'eval',
entry: [
//for hot style updates
'webpack/hot/dev-server',
//refreshes the browser when it can't hot update
'webpack-dev-server/client?http://localhost:8080',
//our entry point
PATHS.app,
PATHS.styles
],
output: {
path: path.join(__dirname, 'public', 'build'),
filename: 'bundle.js',
publicPath: '/build/' //the server will listen in on this path and then proxy Webpack
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: '/node_modules'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', ['css','postcss'])
// include: __dirname + '/src/styles'
},
{
test: /\.(jpg|png)$/,
loader: 'file?hash=sha512&digest=hex&name=[hash].[ext]!image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false',
include: PATHS.images
}
]
},
postcss: function (webpack) {
return [
postcssImport({
addDependencyTo: webpack
}),
precss,
rucksack,
cssnext
];
},
//Since we're running Webpack from our server, need to manually add the
//Hot Replacement plugin
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin('main.css')
]
};
module.exports = validate(config);