M
M
Maxim Ivanov2017-05-30 16:06:03
webpack
Maxim Ivanov, 2017-05-30 16:06:03

How to use webpack's extract plugin for JavaScript files?

There are lines in the polyfills.ts file:

// import js
import "ui-common/source/js/jquery.min.js";
import "ui-common/source/js/materialize.min.js";

I would like to have script tags added to index.html (which is generated by html webpack plugin) with given files
Why can I easily do
// import css
import "ui-common/source/css/normalize.css";

And with my help
new ExtractTextPlugin({
            filename: 'css/style.[hash].css',
            allChunks: true
        })

This css/style.9808572.css file is easily created in the directory and written in the head tag for index.html
But I can’t do script files like that, tell me where to dig?
Now I import files with the js extension like this, but for some reason not all files see the jQuery or Materialize library in the end, I would like it to be a real connection of scripts through tags, then there are no problems with the global scope
{
            test: /\.js$/,
            include: [resolvePath(`${uiCommon}/source/js`)],
            use: ['script-loader']
        },

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question