W3cubDocs

/webpack

script-loader

Install

npm install --save-dev script-loader

Usage

Executes JS script once in global context.

:warning: Doesn't work in NodeJS

##

import exec from 'script.exec.js';

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.exec\.js$/,
        use: [ 'script-loader' ]
      }
    ]
  }
}

Inline

import exec from 'script-loader!./script.js';


Juho Vepsäläinen


Joshua Wiens


Kees Kluskens


Sean Larkin

© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/loaders/script-loader