Commit 8626739c authored by Evan You's avatar Evan You

fix: compat with html-webpack-plugin

fix #1213
parent 7c37a716
...@@ -10,11 +10,6 @@ module.exports = code => code ...@@ -10,11 +10,6 @@ module.exports = code => code
// and transform it into appropriate requests. // and transform it into appropriate requests.
module.exports.pitch = function (remainingRequest) { module.exports.pitch = function (remainingRequest) {
const query = qs.parse(this.resourceQuery.slice(1)) const query = qs.parse(this.resourceQuery.slice(1))
if (query.vue == null) {
return
}
const loaders = this.loaders.slice(1) // remove self const loaders = this.loaders.slice(1) // remove self
// loader.request contains both the resolved loader path and its options // loader.request contains both the resolved loader path and its options
......
...@@ -89,7 +89,11 @@ module.exports = class VueLoaderPlugin { ...@@ -89,7 +89,11 @@ module.exports = class VueLoaderPlugin {
// inject global pitcher (responsible for injecting template compiler // inject global pitcher (responsible for injecting template compiler
// loader & CSS post loader) // loader & CSS post loader)
rawRules.unshift({ rawRules.unshift({
loader: require.resolve('./loaders/pitch') loader: require.resolve('./loaders/pitcher'),
resourceQuery: query => {
const parsed = qs.parse(query.slice(1))
return parsed.vue != null
}
}) })
} }
} }
......
const path = require('path')
const normalizeNewline = require('normalize-newline')
const HTMLPlugin = require('html-webpack-plugin')
const { const {
mfs,
bundle, bundle,
mockRender, mockRender,
mockBundleAndRun mockBundleAndRun
} = require('./utils') } = require('./utils')
const normalizeNewline = require('normalize-newline')
const assertComponent = ({ window, module }, done) => { const assertComponent = ({ window, module }, done) => {
const vnode = mockRender(module, { const vnode = mockRender(module, {
msg: 'hi' msg: 'hi'
...@@ -128,3 +131,20 @@ test('should not duplicate css modules value imports', done => { ...@@ -128,3 +131,20 @@ test('should not duplicate css modules value imports', done => {
done() done()
}) })
}) })
test('html-webpack-plugin', done => {
bundle({
entry: 'basic.vue',
plugins: [
new HTMLPlugin({
inject: true,
template: path.resolve(__dirname, 'fixtures/index.html'),
filename: 'output.html'
})
]
}, () => {
const html = mfs.readFileSync('/output.html', 'utf-8')
expect(html).toMatch('test.build.js')
done()
}, true)
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment