-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
107 lines (104 loc) · 2.45 KB
/
webpack.common.js
File metadata and controls
107 lines (104 loc) · 2.45 KB
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
107
// We are using node's native package 'path'
// https://nodejs.org/api/path.html
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');
// Constant with our paths
const paths = {
DIST: path.resolve(__dirname, 'dist'),
SRC: path.resolve(__dirname, 'src'),
};
// Webpack configuration
module.exports = {
entry: [path.join(paths.SRC, 'index.js')],
output: {
path: paths.DIST,
filename: 'app.bundle.js',
publicPath: '/'
},
plugins: [
new ExtractTextPlugin('style.bundle.css'),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
'babel-loader',
{
loader: 'eslint-loader',
options: {
fix: true
}
}
],
},
{
test: /\.(css|less)$/,
loader: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
localIdentName: '[name]-[local]-[hash:base64:5]',
minify: true,
importLoaders: 2
}
},
'postcss-loader',
'less-loader'],
}),
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name]-[hash:base64:5].[ext]'
}
}
]
},
{
test: /\.svg$/,
issuer: /\.(css|less)/,
use: [
{
loader: 'file-loader',
options: {
name: '[name]-[hash:base64:5].[ext]'
}
}
]
},
{
test: /\.svg$/,
issuer: /\.jsx$/,
exclude: /node_modules/,
loader: 'svg-react-loader',
query: {
classIdPrefix: '[name]-[hash:8]__'
}
},
{
test: /\.modernizrrc.js$/,
loader: 'modernizr-loader'
},
{
test: /\.modernizrrc(\.json)?$/,
loader: 'modernizr-loader!json-loader'
}
],
},
resolve: {
extensions: ['.js', '.jsx'],
// directories named 'shared' will be resolved by lower modules, without ../../../.
modules: ['node_modules', 'shared', path.resolve(__dirname, './src')],
alias: {
modernizr$: path.resolve(__dirname, './.modernizrrc')
}
}
};