Visual Console Client: now the files are built into the console

Former-commit-id: 7bf533c9acb53a64d3a2babd43942248880dbb8e
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-07 17:20:24 +01:00
parent fe61d38686
commit 0dcbec64b4
4 changed files with 33 additions and 22 deletions

View File

@ -3,12 +3,12 @@
"version": "1.0.0",
"description": "Visual Console",
"scripts": {
"clean-build": "node ./scripts/clean-build.js",
"clean-build": "BUILD_PATH=\"pandora_console/include/visual-console\" node ./scripts/clean-build.js",
"prebuild": "npm run clean-build",
"build": "NODE_ENV=production webpack",
"build": "BUILD_PATH=\"pandora_console/include/visual-console\" NODE_ENV=production webpack",
"prebuild:dev": "npm run clean-build",
"build:dev": "NODE_ENV=NODE_ENV=production webpack",
"build:watch": "NODE_ENV=NODE_ENV=production webpack --watch",
"build:dev": "BUILD_PATH=\"pandora_console/include/visual-console\" NODE_ENV=development webpack",
"build:watch": "BUILD_PATH=\"pandora_console/include/visual-console\" NODE_ENV=production webpack --watch",
"format": "prettier",
"lint": "eslint \"src/**/*.ts\"",
"start": "webpack-dev-server --color --mode=development",

View File

@ -5,17 +5,12 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Visual Console Sandbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
type="text/css"
media="screen"
href="visual-console-client.css"
/>
<link rel="stylesheet" type="text/css" media="screen" href="vc.main.css" />
</head>
<body>
<div id="visual-console-container"></div>
</body>
<script src="visual-console-client.min.js"></script>
<script src="vc.main.min.js"></script>
<script>
var container = document.getElementById("visual-console-container");

View File

@ -1,7 +1,16 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs");
const buildPath = path.join(__dirname, "..", "build");
const buildPath = path.join(
__dirname,
"..",
"..",
process.env.BUILD_PATH && process.env.BUILD_PATH.length > 0
? process.env.BUILD_PATH
: "build"
);
if (fs.existsSync(buildPath)) {
fs.readdirSync(buildPath).forEach(file =>

View File

@ -1,16 +1,24 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const dev = process.env.NODE_ENV !== "production";
const entry = path.join(__dirname, "src", "index.ts");
const buildPath = path.join(
__dirname,
"..",
process.env.BUILD_PATH && process.env.BUILD_PATH.length > 0
? process.env.BUILD_PATH
: "build"
);
module.exports = {
mode: dev ? "development" : "production",
entry: __dirname + "/src/index.ts", // Start from this file.
entry, // Start from this file.
output: {
path: __dirname + "/build", // The files will be created here.
filename: dev
? "visual-console-client.min.js"
: "visual-console-client.[hash].min.js",
publicPath: dev ? "" : "pandora_console/include/visual_console/"
path: buildPath, // The files will be created here.
filename: dev ? "vc.[name].min.js" : "vc.[name].[chunkhash:8].min.js"
},
devtool: "source-map",
resolve: {
@ -64,7 +72,8 @@ module.exports = {
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 10000
limit: 10000,
name: "[name].[hash:8].[ext]"
}
}
]
@ -74,9 +83,7 @@ module.exports = {
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: dev
? "visual-console-client.css"
: "visual-console-client.[hash].css",
filename: dev ? "vc.[name].css" : "vc.[name].[contenthash:8].css",
// Disable to remove warnings about conflicting order between imports.
orderWarning: true
})