提交 023e6934 编写于 作者: fxy060608's avatar fxy060608

fix(cli): wrapper-loader without newline

上级 388ee882
......@@ -147,8 +147,9 @@ const v3 = {
rules: [{
test: path.resolve(process.env.UNI_INPUT_DIR, getMainEntry()),
use: [{
loader: isAppService ? 'wrap-loader' : path.resolve(__dirname,
'../../packages/webpack-uni-app-loader/view/main.js'),
loader: isAppService
? path.resolve(__dirname, '../../packages/wrap-loader') : path.resolve(__dirname,
'../../packages/webpack-uni-app-loader/view/main.js'),
options: {
compiler: vueLoader.compiler,
before: [
......
......@@ -113,7 +113,7 @@ module.exports = {
rules: [{
test: path.resolve(process.env.UNI_INPUT_DIR, getMainEntry()),
use: [{
loader: 'wrap-loader',
loader: path.resolve(__dirname, '../../packages/wrap-loader'),
options: {
before: [
beforeCode + statCode + getGlobalUsingComponentsCode()
......@@ -123,7 +123,7 @@ module.exports = {
}, {
test: /App\.vue$/,
use: {
loader: 'wrap-loader',
loader: path.resolve(__dirname, '../../packages/wrap-loader'),
options: {
before: [`<template><App :keepAliveInclude="keepAliveInclude"/></template>`]
}
......
......@@ -106,7 +106,7 @@ module.exports = {
rules: [{
test: path.resolve(process.env.UNI_INPUT_DIR, getMainEntry()),
use: [{
loader: 'wrap-loader',
loader: path.resolve(__dirname, '../../packages/wrap-loader'),
options: {
before: [
beforeCode + statCode
......
Copyright (c) 2014 Daniel Perez Alvarez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# Wrap loader for webpack [![Version](https://img.shields.io/npm/v/wrap-loader.svg)](https://www.npmjs.com/package/wrap-loader) [![Build Status](https://img.shields.io/travis/unindented/wrap-loader.svg)](http://travis-ci.org/unindented/wrap-loader)
Adds custom content before and after the loaded source.
## Installation
```sh
$ npm install --save wrap-loader
```
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
In your `webpack.config.js` file:
```js
module.exports = {
module: {
loaders: [{
test: /\.less$/,
loader: 'style!css!less!wrap?less'
}]
},
wrap: {
less: {
before: [
'@import "~bootstrap/less/variables.less";',
'@import "~bootstrap/less/mixins.less";'
],
after: '@import "~utils/debug.less";'
}
}
};
```
## Meta
* Code: `git clone git://github.com/unindented/wrap-loader.git`
* Home: <https://github.com/unindented/wrap-loader/>
## Contributors
* Daniel Perez Alvarez ([unindented@gmail.com](mailto:unindented@gmail.com))
## License
Copyright (c) 2014 Daniel Perez Alvarez ([unindented.org](http://unindented.org/)). This is free software, and may be redistributed under the terms specified in the LICENSE file.
const utils = require('loader-utils')
module.exports = function (source) {
this.cacheable()
const opts = utils.getOptions(this) || {}
// fixed by xxxxxx 保持行号不变
return [].concat(opts.before, source, opts.after).join('').trim()
// return [].concat(opts.before, source, opts.after).join('\n').trim()
}
{
"_args": [
[
"wrap-loader@0.2.0",
"/Users/fxy/Documents/DCloud/HBuilderX/uniapp-cli"
]
],
"_development": true,
"_from": "wrap-loader@0.2.0",
"_id": "wrap-loader@0.2.0",
"_inBundle": false,
"_integrity": "sha512-Qdhdu7vr2H8dLE2sKySQznOBHXIHbKg7PZ5aqkeBOQHGqxLfcJw/ZlB40j67b1tks9OYqSBCHc+uHtGRCmQYlg==",
"_location": "/wrap-loader",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "wrap-loader@0.2.0",
"name": "wrap-loader",
"escapedName": "wrap-loader",
"rawSpec": "0.2.0",
"saveSpec": null,
"fetchSpec": "0.2.0"
},
"_requiredBy": [
"/@dcloudio/vue-cli-plugin-uni"
],
"_resolved": "https://registry.npmjs.org/wrap-loader/-/wrap-loader-0.2.0.tgz",
"_spec": "0.2.0",
"_where": "/Users/fxy/Documents/DCloud/HBuilderX/uniapp-cli",
"author": {
"name": "Daniel Perez Alvarez",
"email": "unindented@gmail.com",
"url": "http://unindented.org/"
},
"bugs": {
"url": "https://github.com/unindented/wrap-loader/issues"
},
"dependencies": {
"loader-utils": "^1.1.0"
},
"description": "Add custom content before and after the loaded source.",
"devDependencies": {
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-node": "^5.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"nodeunit": "^0.11.1",
"npm-run-all": "^4.0.2"
},
"homepage": "https://github.com/unindented/wrap-loader#readme",
"keywords": [
"wrap",
"webpack"
],
"name": "wrap-loader",
"repository": {
"type": "git",
"url": "git://github.com/unindented/wrap-loader.git"
},
"scripts": {
"test": "run-s test:*",
"test:lint": "eslint .",
"test:unit": "nodeunit test/loader.js"
},
"version": "0.2.0"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册