Skip to content

Commit

Permalink
It was added dev server for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
urdenko committed Apr 18, 2020
1 parent fbdf5a4 commit 1e989a3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
8 changes: 8 additions & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<wanted-print-form></wanted-print-form>
</body>
</html>
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"build": "webpack --mode=production",
"prepublishOnly": "npm i && npm test && npm run build && node .scripts/prepublish.js",
"postpublish": "node .scripts/postpublish.js",
"test": "echo 'It includes my guarantee of quality code.'"
"test": "echo 'It includes my guarantee of quality code.'",
"start": "webpack-dev-server --open"
},
"repository": {
"type": "git",
Expand All @@ -30,7 +31,8 @@
"eslint-plugin-standard": "^4.0.1",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"publishConfig": {
"access": "public"
Expand Down
28 changes: 27 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

module.exports = {
const prodConfig = {
entry: './src/index.ts',
resolve: {
extensions: ['.ts'],
Expand All @@ -12,3 +12,29 @@ module.exports = {
libraryTarget: 'commonjs2',
},
};

const devConfig = {
entry: './src/index.ts',
resolve: {
extensions: ['.ts', '.js'],
modules: ['src', 'node_modules'],
},
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dev'),
library: 'printWanted',
libraryTarget: 'var',
},
devServer: {
contentBase: path.join(__dirname, 'dev'),
port: 8000,
},
};

module.exports = (env, argv) => {
if (argv.mode === 'production') {
return prodConfig;
}

return devConfig;
};

0 comments on commit 1e989a3

Please sign in to comment.