use html-webpack-plugin to inject js file on build

This commit is contained in:
abhijithvijayan 2019-10-25 13:51:02 +05:30
parent a1bbd686c8
commit 23deb6fc2f
3 changed files with 15 additions and 8 deletions

View File

@ -7,7 +7,5 @@
<link rel="stylesheet" href="css/options.css" /> <link rel="stylesheet" href="css/options.css" />
</head> </head>
<body> <body></body>
<script src="js/options.js"></script>
</body>
</html> </html>

View File

@ -7,7 +7,5 @@
<link rel="stylesheet" href="css/popup.css" /> <link rel="stylesheet" href="css/popup.css" />
</head> </head>
<body> <body></body>
<script src="js/popup.js"></script>
</body>
</html> </html>

View File

@ -21,6 +21,7 @@ module.exports = {
}, },
plugins: [ plugins: [
new webpack.ProgressPlugin(),
new FixStyleOnlyEntriesPlugin({ silent: true }), new FixStyleOnlyEntriesPlugin({ silent: true }),
new CleanWebpackPlugin({ new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), `extension/${process.env.TARGET}`)], cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), `extension/${process.env.TARGET}`)],
@ -31,8 +32,18 @@ module.exports = {
{ from: 'src/assets', to: 'assets' }, { from: 'src/assets', to: 'assets' },
{ from: `src/manifests/${process.env.TARGET}.json`, to: 'manifest.json' }, { from: `src/manifests/${process.env.TARGET}.json`, to: 'manifest.json' },
]), ]),
new webpack.ProgressPlugin(), new HtmlWebpackPlugin({
new HtmlWebpackPlugin(), template: 'src/options.html',
// inject: false,
chunks: ['options'],
filename: 'options.html',
}),
new HtmlWebpackPlugin({
template: 'src/popup.html',
// inject: false,
chunks: ['popup'],
filename: 'popup.html',
}),
], ],
module: { module: {