Skip to content

Commit 912ec9c

Browse files
committed
update tests to use Webpack 2
1 parent c323cf7 commit 912ec9c

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module.exports = function (content) {
129129
var lang = part.lang || defaultLang[type]
130130
var loader = loaders[lang]
131131
var rewriter = type === 'styles' ? styleRewriter + (scoped ? '&scoped=true!' : '!') : ''
132-
var injectString = (type === 'script' && query.inject) ? 'inject!' : ''
132+
var injectString = (type === 'script' && query.inject) ? 'inject-loader!' : ''
133133
if (loader !== undefined) {
134134
// add css modules
135135
if (type === 'styles') {

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,30 @@
5353
"chai": "^3.0.0",
5454
"coffee-loader": "^0.7.2",
5555
"coffee-script": "^1.10.0",
56-
"css-loader": "^0.23.1",
56+
"css-loader": "^0.26.0",
5757
"eslint": "^2.9.0",
5858
"eslint-config-vue": "^1.0.0",
5959
"eslint-plugin-html": "^1.5.2",
6060
"expose-loader": "^0.7.1",
61-
"extract-text-webpack-plugin": "^1.0.1",
62-
"file-loader": "^0.8.5",
63-
"inject-loader": "^2.0.1",
61+
"extract-text-webpack-plugin": "^2.0.0-beta.4",
62+
"file-loader": "^0.9.0",
63+
"inject-loader": "^2.0.0",
6464
"jsdom": "^9.2.1",
6565
"memory-fs": "^0.3.0",
6666
"mkdirp": "^0.5.1",
6767
"mocha": "^2.2.5",
6868
"node-libs-browser": "^1.0.0",
69+
"mocha": "^3.2.0",
70+
"node-libs-browser": "^2.0.0",
6971
"normalize-newline": "^3.0.0",
7072
"postcss": "^5.0.21",
7173
"pug": "^2.0.0-beta6",
7274
"rimraf": "^2.4.0",
7375
"stylus": "^0.54.5",
7476
"stylus-loader": "^2.0.0",
75-
"sugarss": "^0.1.3",
76-
"vue": "^2.0.4",
77-
"webpack": "^1.12.2"
77+
"sugarss": "^0.2.0",
78+
"vue": "^2.1.0",
79+
"vue-template-compiler": "^2.1.0",
80+
"webpack": "^2.1.0-beta.27"
7881
}
7982
}

test/test.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ var ExtractTextPlugin = require("extract-text-webpack-plugin")
1212
var compiler = require('../lib/template-compiler')
1313
var normalizeNewline = require('normalize-newline')
1414

15-
var loaderPath = 'expose?vueModule!' + path.resolve(__dirname, '../')
15+
var loaderPath = 'expose-loader?vueModule!' + path.resolve(__dirname, '../index.js')
1616
var mfs = new MemoryFS()
1717
var globalConfig = {
1818
output: {
1919
path: '/',
2020
filename: 'test.build.js'
2121
},
2222
module: {
23-
loaders: [
23+
rules: [
2424
{
2525
test: /\.vue$/,
2626
loader: loaderPath
@@ -30,7 +30,17 @@ var globalConfig = {
3030
}
3131

3232
function bundle (options, cb) {
33+
var vueOptions = options.vue
34+
delete options.vue
3335
var config = Object.assign({}, globalConfig, options)
36+
37+
// assign vue Options
38+
if (vueOptions) {
39+
config.plugins = (config.plugins || []).concat(new webpack.LoaderOptionsPlugin({
40+
vue: vueOptions
41+
}))
42+
}
43+
3444
var webpackCompiler = webpack(config)
3545
webpackCompiler.outputFileSystem = mfs
3646
webpackCompiler.run(function (err, stats) {
@@ -250,8 +260,8 @@ describe('vue-loader', function () {
250260
entry: './test/fixtures/extract-css.vue',
251261
vue: {
252262
loaders: {
253-
css: ExtractTextPlugin.extract('css'),
254-
stylus: ExtractTextPlugin.extract('css?sourceMap!stylus')
263+
css: ExtractTextPlugin.extract('css-loader'),
264+
stylus: ExtractTextPlugin.extract('css-loader?sourceMap!stylus-loader')
255265
}
256266
},
257267
plugins: [
@@ -269,6 +279,7 @@ describe('vue-loader', function () {
269279
test({
270280
entry: './test/fixtures/inject.js'
271281
}, function (window) {
282+
// console.log(window.injector.toString())
272283
var module = interopDefault(window.injector({
273284
'./service': {
274285
msg: 'Hello from mocked service!'
@@ -292,7 +303,7 @@ describe('vue-loader', function () {
292303
}
293304
},
294305
module: {
295-
loaders: [
306+
rules: [
296307
{ test: /\.vue$/, loader: loaderPath },
297308
{ test: /\.png$/, loader: 'file-loader?name=[name].[hash:6].[ext]' }
298309
]

0 commit comments

Comments
 (0)