
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Static Web Development Eviroment
swde will scaffold a flexible enviroment for developing static web pages or components.
i18n global object.Used to create:
npm i @ascari/swde --save
Create a build.js file
const swde = require('swde');
swde({
src: './src',
dist: './dist',
html: {
output: {
index: { // index.html
path: 'home.html',
vars: {
pageName: 'Home'
},
elements: {
header: 'elements/header.html'
}
}
},
}
})
.then(() => console.log('Build done.'))
.catch(error => console.log(error));
Pro-trip
Use nodemon on build.js to trigger a rebuild when changing files.
Use http-server or similar in the dist folder to see the result.
Use a live-reload tool to detect file changes and refresh the page.
swde comes as a single function that takes either a configuration object or an array of configuration objects to process async in series.
const swde = require('swde');
const config = { ... };
swde(config)
.then(() => console.log("Done!"))
.catch(error => console.log("Error:", error));
The Configuration Object requires two path properties and at least 1 module property to be set in order to execute.
const config = {
src: 'path/to/source/folder',
dist: 'path/to/output/folder',
<some module>: { module options... }
};
swde(config)
.then(() => console.log("Done!"))
.catch(error => console.log("Error:", error));
The src property specifies where the source files for the current project can be found.
It is determined as the root Working Source Directory, and all modules process source files relative to this path.
Defaults to: ./src
The dist property specifies where the output files for the current project can be found.
It is determined as the Working Dist Directory, and all modules place their output relative to this path.
Defaults to: ./dist
Modules are the backbone of swde and are chosen by including their name or namespace in the Configuration Object.
Currently there are 12 modules:
const config = {
src: 'path/to/source/folder',
dist: 'path/to/output/folder',
js: {
path: 'js',
distPath: '.',
...
}
};
swde(config)
.then(() => console.log("Done!"))
.catch(error => console.log("Error:", error));
All module properties must have a Object value or a Boolean true in order to activate the module. Each module has its own set of options or configuration, however, currently all modules have at least a path property that defines a working path relative to the src & dist paths, in order to work with source and output files respectively.
The path property defines the folder paths for both the Working Source Directory and Working Dist Directory destinations. In order to specify different paths, you can use the srcPath and distPath properties to further specify the paths the module will work with.
In the example shown above, The source folder for javascript files will be: <src>/js/ and the output location will be <dist>/.
The js module places your JavaScript files under one house.
import & export are usedvariables object, where it is used in the html module to allow you to inline the output in a html file that is created.swde({
js: {
path: 'js',
index: 'index.js',
filename: 'bundle.js',
libs: [],
include: [],
uglifyOptions: { ... },
}
})
path String
The js module option requires a working path relative to the src & dist options. By default the path is set to "js", so, the working paths are:
<src>/js/ For source JavaScript files<dist>/js/ For output filesIf you want to specify a different dist path from a src path, you can use the distPath & srcPath options, respectively.
swde({
js: {
path: 'js',
distPath: '.'
...
}
})
The working paths for the previous example where distPath is specified is:
<src>/js/ For source JavaScript files<dist>/ For output filesfilename String
The filename module option is required when the noFile option is false. This specifies what the filename of the compiled JavaScript will be. By default the name of the file is "bundle.js"
The dist options, as well as the js.path or js.distPath options determine the overall path of the JavaScript bundle that is created. filepath is:<dist>/<js.distPath>/<js.filename>
libs Array
The libs module option is used to specify javascript files that will not be processed, however they will be concated at the beggining of the bundle that is created.
Used to include files like a minified jquery that does not require processing, but should be included within the JavaScript bundle that is created.
All paths are relative to the src or srcPath module options.
include Array
The include module option is used to specify other paths to search for JavaScript files for when using the import keyword in your project.
PATHS ARE NOT RELATIVE MUST BE FULL PATH
uglifyOptions Object Options fed directly to UglifyJs the minifier used by swde.
...
require('swde')({
src: './src',
dist: '.',
env: 'production',
js: {
path: '.',
filename: 'complex.min.js',
include: [
'/path/to/third-party/libs',
'/path/to/custom/libs'
]
}
})
.then(() => console.log('Done!'))
.catch(e => console.log(e))
This example takes multiple javascript files from various locations to build a single minified javascript file.
./src./src/index.js./complex.min.jsThe project folder will loook like the following after a build:
./src/index.js
/other.js
/other-file.js
./complex.min.js
./build.js
require('swde')({
src: './src',
dist: './dist',
env: 'production',
js: {
path: 'js',
filename: 'component.min.js',
},
less: {
path: 'less',
filename: 'component.min.css',
},
html: {
path: 'html',
distPath: '.',
output: {
component: {
path: 'index.html',
vars: {
name: 'ComponentName'
},
elements: {
button: 'elements/button.html',
textbox: 'elements/textbox.html',
}
},
index: {
path: 'example.html'
},
}
}
})
.then(() => console.log('Done!'))
.catch(e => console.log(e))
This example takes js, less and html files and outputs a component in html, javascript and css, as well as a example page. This project will allow you to create your own re-usable components.
The project folder will loook like the following after a build:
./src
/js
/index.js
/less
/index.less
/html
/index.html
/example.html
./dist
/index.html
/component.html
/component.min.js
/component.min.css
./build.js
MIT
FAQs
Static Web Development Enviroment
We found that swde demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.