chore(webpack): Add npm run serve command

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-05-17 09:27:39 +02:00
committed by backportbot-nextcloud[bot]
parent b0ebb34fb8
commit cfd0fc828f
2 changed files with 12 additions and 6 deletions

View File

@@ -20,6 +20,7 @@
"build": "NODE_ENV=production webpack --progress --config webpack.js", "build": "NODE_ENV=production webpack --progress --config webpack.js",
"dev": "NODE_ENV=development webpack --progress --config webpack.js", "dev": "NODE_ENV=development webpack --progress --config webpack.js",
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js", "watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
"serve": "webpack serve --node-env development --allowed-hosts all --config webpack.js",
"lint": "eslint --ext .js,.vue src", "lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix", "lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint src", "stylelint": "stylelint src",

View File

@@ -5,6 +5,7 @@ const StyleLintPlugin = require('stylelint-webpack-plugin')
const buildMode = process.env.NODE_ENV const buildMode = process.env.NODE_ENV
const isDev = buildMode === 'development' const isDev = buildMode === 'development'
const isDevServer = process.env.WEBPACK_DEV_SERVER;
webpackConfig.entry = { webpackConfig.entry = {
...webpackConfig.entry, ...webpackConfig.entry,
@@ -15,12 +16,16 @@ webpackConfig.entry = {
'card-reference': path.join(__dirname, 'src', 'init-card-reference.js'), 'card-reference': path.join(__dirname, 'src', 'init-card-reference.js'),
} }
webpackConfig.stats = { if (isDevServer) {
context: path.resolve(__dirname, 'src'), webpackConfig.output.publicPath = 'http://127.0.0.1:3000/'
assets: true, } else {
entrypoints: true, webpackConfig.stats = {
chunks: true, context: path.resolve(__dirname, 'src'),
modules: true, assets: true,
entrypoints: true,
chunks: true,
modules: true,
}
} }
webpackConfig.plugins.push( webpackConfig.plugins.push(