Skip to content

Commit 0c6fce7

Browse files
Salama AshoushSalama Ashoush
Salama Ashoush
authored and
Salama Ashoush
committed
Add custom asset folders
1 parent 04b54c8 commit 0c6fce7

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/index.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ import ReactDOM from 'react-dom';
33
import App from './App.jsx';
44

55
ReactDOM.render(<App />, document.getElementById('app'));
6-
module.hot.accept();

webpack/paths.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ module.exports = {
55
outputPath: path.resolve(__dirname, '../', 'build'),
66
entryPath: path.resolve(__dirname, '../', 'src/index.jsx'),
77
templatePath: path.resolve(__dirname, '../', 'src/template.html'),
8+
imagesFolder: 'images',
9+
fontsFolder: 'fonts',
10+
cssFolder: 'css',
11+
jsFolder: 'js',
812
};

webpack/webpack.common.js

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module.exports = {
1111
test: /\.(js|jsx)$/,
1212
loader: 'eslint-loader',
1313
exclude: /(node_modules)/,
14+
options: {
15+
emitWarning: process.env.NODE_ENV !== 'production',
16+
},
1417
},
1518
{
1619
test: /\.(js|jsx)$/,
@@ -22,6 +25,9 @@ module.exports = {
2225
use: [
2326
{
2427
loader: 'file-loader',
28+
options: {
29+
outputPath: commonPaths.imagesFolder,
30+
},
2531
},
2632
],
2733
},
@@ -30,6 +36,9 @@ module.exports = {
3036
use: [
3137
{
3238
loader: 'file-loader',
39+
options: {
40+
outputPath: commonPaths.fontsFolder,
41+
},
3342
},
3443
],
3544
},

webpack/webpack.prod.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const CleanWebpackPlugin = require('clean-webpack-plugin');
55
module.exports = {
66
mode: 'production',
77
output: {
8-
filename: '[name].[hash].js',
8+
filename: `${commonPaths.jsFolder}/[name].[hash].js`,
99
path: commonPaths.outputPath,
1010
chunkFilename: '[name].[chunkhash].js',
1111
},
@@ -18,9 +18,11 @@ module.exports = {
1818
],
1919
},
2020
plugins: [
21-
new CleanWebpackPlugin(['dist'], { root: commonPaths.root }),
21+
new CleanWebpackPlugin([commonPaths.outputPath.split('/').pop()], {
22+
root: commonPaths.root,
23+
}),
2224
new MiniCssExtractPlugin({
23-
filename: '[name].css',
25+
filename: `${commonPaths.cssFolder}/[name].css`,
2426
chunkFilename: '[id].css',
2527
}),
2628
],

0 commit comments

Comments
 (0)