This module is deprecated and will no longer be maintained.
It has a known issue of generating non-deterministic hashes (see #49, #56, #60). Do not use it.
In most cases, you can replace the functionality by using raw-loader instead:
- import('script-loader!someScript.js')
+ import('raw-loader!someScript.js').then(rawModule => eval.call(null, rawModule.default))If you need some transformations to be applied to the script you want to load, you may need to find or write yourself a separate loader for that. Some documentation that might be helpful:
- https://webpack.js.org/loaders/
 - https://webpack.js.org/concepts/loaders/
 - https://webpack.js.org/contribute/writing-a-loader/
 
npm install --save-dev script-loaderExecutes JS script once in global context.
⚠️ Doesn't work in NodeJS
import './script.exec.js';webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.exec\.js$/,
        use: [ 'script-loader' ]
      }
    ]
  }
}import 'script-loader!./script.js';| Name | Type | Default | Description | 
|---|---|---|---|
sourceMap | 
{Boolean} | 
false | 
Enable/Disable Sourcemaps | 
useStrict | 
{Boolean} | 
true | 
Enable/Disable useStrict | 
Type: Boolean
Default: false
To include source maps set the sourceMap option.
webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.script\.js$/,
        use: [
          {
            loader: 'script-loader',
            options: {
              sourceMap: true,
            },
          },
        ]
      }
    ]
  }
}Type: Boolean
Default: true
To disable use strict set the useStrict option to false.
webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.script\.js$/,
        use: [
          {
            loader: 'script-loader',
            options: {
              useStrict: false,
            },
          },
        ]
      }
    ]
  }
}| 
         Juho Vepsäläinen  | 
      
         Joshua Wiens  | 
      
         Kees Kluskens  | 
      
         Sean Larkin  |