-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
174 lines (164 loc) · 4.72 KB
/
webpack.config.js
File metadata and controls
174 lines (164 loc) · 4.72 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
process.traceDeprecation = true;
var webpack = require('webpack');
var path = require('path');
/**
* Custom webpack plugins
*/
var Clean = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var AssetsPlugin = require('assets-webpack-plugin');
module.exports = {
// debug: true,
// devtool: "source-map",
mode: 'production',
entry: {
main: [
'./assets/javascripts/all.js',
'./assets/stylesheets/site.css.scss',
],
},
output: {
path: __dirname + '/docs',
filename: 'assets/javascripts/[name].bundle.js',
// filename: 'assets/javascripts/[name]_[hash].bundle.js',
publicPath: "../../"
},
// Plugin/loader specific-configuration
plugins: [
new webpack.DefinePlugin({
DEVELOPMENT: true
}),
new ExtractTextPlugin("[name].css", {
allChunks: true
})
],
resolve: {
modules: [
path.resolve(__dirname, 'assets/stylesheets'),
path.resolve(__dirname, 'assets/javascripts'),
path.resolve(__dirname, 'assets/images'),
path.resolve(__dirname, 'assets/fonts'),
path.join(__dirname, 'node_modules')
]
},
// Same issue, for loaders like babel
resolveLoader: {
modules: [path.join(__dirname, 'node_modules')]
},
module: {
rules: [
{
test: /\.scss$/,
exclude: /node_modules|\.tmp|vendor|docs/,
loader: 'import-glob-loader',
enforce: 'pre'
},
{
test: /\.js?$/,
exclude: /node_modules|docs/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['es2015']
}
},
// {
// loader: 'eslint-loader'
// }
]
},
{
test:/\.(png|jpe?g|gif)$/,
exclude:/node_modules|docs/,
use: {
loader: 'url-loader',
options: {
limit: 1024,
name: 'assets/images/[name].[ext]'
}
}
},
{
test: /\.scss$/,
exclude: /node_modules|\.tmp|vendor|docs/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
minimize: false,
sourceMap: false
}
},
{
loader: 'sass-loader'
},
// {
// loader: 'postcss-loader',
// options: {
// plugins: [
// require('postcss-cssnext')({
// map: false,
// compress: false
// }),
// require('postcss-sass')
// ]
// }
// }
]
})
},
{
test: /\.(css|mcss)$/,
// The ExtractTextPlugin pulls all CSS out into static files
// rather than inside the JavaScript/webpack bundle
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
minimize: false,
sourceMap: false,
modules: true,
importLoaders: 2,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
{
loader: 'postcss-loader',
}
]
})
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
name: 'assets/fonts/[name].[ext]'
}
}
},
//{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
//{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
//{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
//{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
//{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream"},
//{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file"},
//{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml"}
],
},
plugins: [
// new Clean(['.tmp']),
new ExtractTextPlugin('assets/stylesheets/[name].bundle.css', {
// new ExtractTextPlugin('assets/stylesheets/[name]_[hash].bundle.css', {
allChunks: true
}),
new CopyWebpackPlugin([{ from: 'assets/images', to: 'assets/images' }, { from: 'static' }]),
new AssetsPlugin({fullPath: false})
],
};