Skip to content

Commit c7bc089

Browse files
committed
update webpack config
1 parent 6e1ebe1 commit c7bc089

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

webpack/webpack.common.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ module.exports = {
88
vendor: './statik/scripts/vendor.js'
99
},
1010
output: {
11-
filename: '[name].[chunkhash].bundle.js',
11+
filename: '[name].js',
1212
path: path.resolve('dist')
1313
},
1414
module: {
1515
rules: [
16+
{
17+
test: /\.html$/,
18+
use: 'html-loader'
19+
},
1620
{
1721
test: /\.js$/,
1822
exclude: /node_modules/,
@@ -24,14 +28,25 @@ module.exports = {
2428
}
2529
},
2630
{
27-
test: /\.(eot|svg|ttf|woff2?)$/,
28-
exclude: /images/,
31+
test: /\.(eot|ttf|woff2?)$/,
32+
use: [
33+
{
34+
loader: 'file-loader',
35+
options: {
36+
name: '[name].[ext]',
37+
useRelativePath: true
38+
}
39+
}
40+
]
41+
},
42+
{
43+
test: /\.(gif|jpg|png|svg|ico)$/,
2944
use: [
3045
{
3146
loader: 'file-loader',
3247
options: {
3348
name: '[name].[ext]',
34-
outputPath: 'fonts/'
49+
useRelativePath: true
3550
}
3651
}
3752
]

webpack/webpack.dev.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,14 @@ const path = require('path');
33

44
const common = require('./webpack.common');
55

6-
module.exports = merge(common, {
6+
module.exports = merge.smart(common, {
77
mode: 'development',
88
devtool: 'eval',
99
module: {
1010
rules: [
11-
{
12-
test: /\.html$/,
13-
use: 'html-loader'
14-
},
1511
{
1612
test: /\.css$/,
1713
use: ['style-loader', 'css-loader']
18-
},
19-
{
20-
test: /\.(gif|jpg|png|svg|ico)$/,
21-
include: path.resolve('statik', 'images'),
22-
use: ['file-loader']
2314
}
2415
]
2516
},

webpack/webpack.prod.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
const autoprefixer = require('autoprefixer');
22
const merge = require('webpack-merge');
3-
const path = require('path');
43
const webpack = require('webpack');
54
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
65
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
76
const UglifyJsWebpackPlugin = require('uglifyjs-webpack-plugin');
87

98
const common = require('./webpack.common');
109

11-
module.exports = merge(common, {
10+
module.exports = merge.smart(common, {
1211
mode: 'production',
1312
devtool: 'source-map',
13+
output: {
14+
filename: '[name].[chunkhash].js'
15+
},
1416
module: {
1517
rules: [
1618
{
@@ -40,17 +42,7 @@ module.exports = merge(common, {
4042
},
4143
{
4244
test: /\.(gif|jpg|png|svg|ico)$/,
43-
include: path.resolve('statik', 'images'),
44-
use: [
45-
{
46-
loader: 'file-loader',
47-
options: {
48-
name: '[name].[ext]',
49-
useRelativePath: true
50-
}
51-
},
52-
'image-webpack-loader'
53-
]
45+
use: 'image-webpack-loader'
5446
}
5547
]
5648
},
@@ -75,8 +67,7 @@ module.exports = merge(common, {
7567
},
7668
plugins: [
7769
new MiniCssExtractPlugin({
78-
filename: '[name].bundle.css',
79-
chunkFilename: '[id].css'
70+
filename: '[name].[chunkhash].css'
8071
}),
8172
new UglifyJsWebpackPlugin({
8273
sourceMap: true

0 commit comments

Comments
 (0)