feat(webpack-react): mv webpack config to config folder
This commit is contained in:
parent
35ffd8187e
commit
426868de20
|
@ -4,11 +4,11 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
//bundle *.js from this entry point
|
//bundle *.js from this entry point
|
||||||
entry: path.resolve(__dirname, 'src/index.js'),
|
entry: path.resolve(__dirname, '../src/index.js'),
|
||||||
//create output file to be linked to index.html
|
//create output file to be linked to index.html
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].bundle.js',
|
filename: '[name].bundle.js',
|
||||||
path: path.resolve(__dirname, './dist'),
|
path: path.resolve(__dirname, '../dist'),
|
||||||
clean: true,
|
clean: true,
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
|
@ -18,7 +18,7 @@ module.exports = {
|
||||||
//test all *.jsx (e.g. React.js) using babel-loader
|
//test all *.jsx (e.g. React.js) using babel-loader
|
||||||
test: /\.(js|jsx)$/,
|
test: /\.(js|jsx)$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
include: path.resolve(__dirname, 'src'),
|
include: path.resolve(__dirname, '../src'),
|
||||||
use: ['babel-loader'],
|
use: ['babel-loader'],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -30,7 +30,7 @@ module.exports = {
|
||||||
// create an plugin instance so that you can use it several times anywhere
|
// create an plugin instance so that you can use it several times anywhere
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
title: 'Production',
|
title: 'Production',
|
||||||
template: path.resolve(__dirname, "public/index.html")
|
template: path.resolve(__dirname, "../public/index.html")
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
};
|
};
|
|
@ -9,6 +9,6 @@ module.exports = merge(common, {
|
||||||
//enable strong source mapping
|
//enable strong source mapping
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
||||||
devServer: {
|
devServer: {
|
||||||
static: path.resolve(__dirname, 'dist'),
|
static: path.resolve(__dirname, '../dist'),
|
||||||
},
|
},
|
||||||
});
|
});
|
|
@ -14,8 +14,8 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack serve --open --config webpack.dev.js",
|
"start": "webpack serve --open --config config/webpack.dev.js",
|
||||||
"build": "webpack --config webpack.prod.js"
|
"build": "webpack --config config/webpack.prod.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
"@babel/core": "^7.18.2",
|
||||||
|
|
|
@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
|
||||||
import Home from './pages/home';
|
import Home from './pages/home';
|
||||||
//TODO remove debugging
|
//TODO remove debugging
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
console.log('development mode!');
|
console.log('development mode');
|
||||||
}
|
}
|
||||||
//since react 18
|
//since react 18
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
//path is used to resolve properly across the OS
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
//bundle *.js from this entry point
|
|
||||||
entry: path.resolve(__dirname, './src/index.js'),
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
//test all *.js using babel-loader
|
|
||||||
//test all *.jsx (e.g. React.js) using babel-loader
|
|
||||||
test: /\.(js|jsx)$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
use: ['babel-loader'],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['*', '.js', '.jsx'],
|
|
||||||
},
|
|
||||||
//create output file to be linked to index.html
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, './public'),
|
|
||||||
filename: 'bundle.js',
|
|
||||||
},
|
|
||||||
};
|
|
Loading…
Reference in New Issue