Add prod and dev configs, dev-server
- Broke our webpack.config file into 3 files - webpack.common.js, webpack.dev.js, and webpack.prod.js - installed webpack-merge to share the common functionality - updated our package.json to use the new config files - installed webpack-dev-server and added it to start script in package.json
This commit is contained in:
parent
c932911657
commit
eb66c0dc93
1158
package-lock.json
generated
1158
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,8 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack --config webpack.config.js"
|
"start": "webpack-dev-server --config webpack.dev.js --open",
|
||||||
|
"build": "webpack --config webpack.prod.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
@ -18,6 +19,8 @@
|
|||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"webpack": "^4.29.6",
|
"webpack": "^4.29.6",
|
||||||
"webpack-cli": "^3.2.3"
|
"webpack-cli": "^3.2.3",
|
||||||
|
"webpack-dev-server": "^3.2.1",
|
||||||
|
"webpack-merge": "^4.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,7 @@ const path = require("path");
|
|||||||
var HtmlWebpackPlugin = require("html-webpack-plugin");
|
var HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: "development",
|
|
||||||
entry: "./src/index.js",
|
entry: "./src/index.js",
|
||||||
output: {
|
|
||||||
filename: "main.[contentHash].js",
|
|
||||||
path: path.resolve(__dirname, "dist")
|
|
||||||
},
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: "./src/template.html"
|
template: "./src/template.html"
|
11
webpack.dev.js
Normal file
11
webpack.dev.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
const path = require("path");
|
||||||
|
const common = require("./webpack.common");
|
||||||
|
const merge = require("webpack-merge");
|
||||||
|
|
||||||
|
module.exports = merge(common, {
|
||||||
|
mode: "development",
|
||||||
|
output: {
|
||||||
|
filename: "main.js",
|
||||||
|
path: path.resolve(__dirname, "dist")
|
||||||
|
}
|
||||||
|
});
|
11
webpack.prod.js
Normal file
11
webpack.prod.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
const path = require("path");
|
||||||
|
const common = require("./webpack.common");
|
||||||
|
const merge = require("webpack-merge");
|
||||||
|
|
||||||
|
module.exports = merge(common, {
|
||||||
|
mode: "production",
|
||||||
|
output: {
|
||||||
|
filename: "main.[contentHash].js",
|
||||||
|
path: path.resolve(__dirname, "dist")
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user