npm install --save-dev script-loader
在全局上下文(global context)执行一次 JS 脚本。
:警告: 在 node.js 中不会运行
##
import exec from 'script.exec.js';
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.exec\.js$/,
use: [ 'script-loader' ]
}
]
}
}
import exec from 'script-loader!./script.js';
sourceMap
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,
},
},
]
}
]
}
}
Juho Vepsäläinen |
Joshua Wiens |
Kees Kluskens |
Sean Larkin |