webpack: split configs into prod/dev
This commit is contained in:
parent
63fa42e1e3
commit
f6d07eb657
@ -1,6 +1,7 @@
|
||||
env:
|
||||
browser: true
|
||||
es2021: true
|
||||
node: true
|
||||
extends: eslint:recommended
|
||||
overrides: []
|
||||
parserOptions:
|
||||
|
3
package-lock.json
generated
3
package-lock.json
generated
@ -16,7 +16,8 @@
|
||||
"style-loader": "^3.3.1",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1",
|
||||
"webpack-dev-server": "^4.11.1"
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"webpack-merge": "^5.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discoveryjs/json-ext": {
|
||||
|
@ -5,9 +5,9 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "webpack",
|
||||
"lint": "eslint --ext .js,.jsx src",
|
||||
"start": "webpack serve --open"
|
||||
"build": "webpack --config webpack.prod.js",
|
||||
"lint": "eslint --ext .js,.jsx src *.js",
|
||||
"start": "webpack serve --open --config webpack.dev.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -40,6 +40,7 @@
|
||||
"style-loader": "^3.3.1",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1",
|
||||
"webpack-dev-server": "^4.11.1"
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"webpack-merge": "^5.8.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,14 @@
|
||||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const path = require("path");
|
||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
|
||||
const pages = ["index", "aes"];
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
entry: pages.reduce((config, page) => {
|
||||
config[page] = `./src/${page}.js`;
|
||||
return config;
|
||||
}, {}),
|
||||
devtool: 'inline-source-map',
|
||||
devServer: {
|
||||
static: './dist',
|
||||
},
|
||||
output: {
|
||||
filename: "[name].js",
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
@ -44,7 +39,7 @@ module.exports = {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/i,
|
||||
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
||||
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
||||
},
|
||||
],
|
||||
},
|
10
webpack.dev.js
Normal file
10
webpack.dev.js
Normal file
@ -0,0 +1,10 @@
|
||||
const { merge } = require("webpack-merge");
|
||||
const common = require("./webpack.common.js");
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: "development",
|
||||
devtool: "inline-source-map",
|
||||
devServer: {
|
||||
static: "./dist",
|
||||
},
|
||||
});
|
7
webpack.prod.js
Normal file
7
webpack.prod.js
Normal file
@ -0,0 +1,7 @@
|
||||
const { merge } = require("webpack-merge");
|
||||
const common = require("./webpack.common.js");
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: "production",
|
||||
devtool: "source-map",
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user