
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
inline-resource-plugin
Advanced tools
A webpack plugin to embed css/js resource in the html with inline-source module.
A webpack plugin to embed css/js resource in the html with inline-source module.
$ npm install inline-resource-plugin --save-dev
<!-- ./build/hello.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<link href="inline.css" inline>
<script src="inline.js" inline></script>
</head>
<body>
<div class="container">
<h1>hello world!</h1>
</div>
</body>
</html>
/* ./src/inline.js */
function Person() {
}
Person.prototype.sayHello = function () {
var word = 'hello';
console.log(word);
};
/* ./src/inline.css */
.container {
border: 1px solid #000000;
}
Output:
<!-- ./build/hello.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<style>.container{border:1px solid #000}</style>
<script>function Person(){}Person.prototype.sayHello=function(){var o="hello";console.log(o)};</script>
</head>
<body>
<div class="container">
<h1>hello world!</h1>
</div>
</body>
</html>
Available options
include:
compile
: If the file that you want to embed need to be compiled(such as ES6 or require), you can pass 'true'.(default false
)compress
: enable/disable compression.(default true
)rootpath
: path used for resolving inlineable paths.template
: the path of your template file.This option is used for finding out the files which need to embed into the template.(required)test
: the file which you want to execute embed task.If you have multiple templates,you'd better use regx to specify the template that you want to execute inline task.filename
: If you decide to use the other plugins such as HtmlWebpackPlugin to generate template file,you can ignore this option.Or you can pass the path and we will generate template file by ourselves.note: test
and filename
option at least one is needed(Refer to the example below).
// webpack.config.js example
const HtmlWebpackPlugin = require('html-webpack-plugin');
const InlineResourcePlugin = require('inline-resource-plugin');
module.exports = {
entry: {
hello: './src/hello'
},
output: {
path: './build',
publicPath: '/inline-resource-plugin/example/build/',
filename: '[name].js'
},
plugins: [
new HtmlWebpackPlugin({
filename: 'hello_result.html',
template: './src/hello.html',
inject: 'body'
}),
new InlineResourcePlugin({ // this InlineResourcePlugin is work with HtmlWebpackPlugin(As it has supplied 'test' option)
compile: true,
compress: true,
rootpath: './src',
template: './src/hello.html', // Just keep the same with the 'template' option of HtmlWebpackPlugin
test: /^hello_result\.html$/ // A regular expression that match the 'filename' option of HtmlWebpackPlugin
}),
new InlineResourcePlugin({ // this InlineResourcePlugin is work alone(As it has supplied 'filename' option)
compile: false,
compress: true,
rootpath: './src',
template: './src/world.html',
filename: 'world_result.html' // If you use 'filename' option, you don't need to supply 'test' option
})
]
};
note: You can find this demo in the example directory.
Available event include:
inline-resource-plugin-html-after-emit
: This event represent that the compile and embed task has been completed.You may need it when you use this plugin with hot module replacement feature.example:
compiler.plugin('inline-resource-plugin-html-after-emit', function (data, callback) {
hotMiddleware.publish({action: 'reload'});
callback();
});
FAQs
A webpack plugin to embed css/js resource in the html with inline-source module.
The npm package inline-resource-plugin receives a total of 22 weekly downloads. As such, inline-resource-plugin popularity was classified as not popular.
We found that inline-resource-plugin 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.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.