feat: basic webpack-chain setup

This commit is contained in:
Igor Randjelovic
2020-11-14 14:27:52 +01:00
parent e704f744b7
commit 9250bf2222
5 changed files with 54 additions and 4 deletions

View File

@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`vue configuration works 1`] = `
Object {
"entry": Object {
"bundle.js": Array [
"bundle.js",
],
},
"module": Object {
"rules": Array [
Object {
"test": /\\\\\\.vue\\$/,
"use": Array [
Object {
"loader": "vue-loader",
"options": Object {
"compiler": "nativescript-vue-template-compiler",
},
},
],
},
],
},
}
`;

View File

@ -0,0 +1,7 @@
import { vueConfig } from '@nativescript/webpack';
describe('vue configuration', () => {
it('works', () => {
expect(vueConfig('')).toMatchSnapshot();
});
});

View File

@ -2,5 +2,9 @@ import { Configuration } from 'webpack';
// todo: add base configuration that's shared across all flavors // todo: add base configuration that's shared across all flavors
export default function (env): Configuration { export default function (env): Configuration {
return {}; return {
entry: {
'bundle.js': 'bundle.js',
},
};
} }

View File

@ -1,10 +1,23 @@
import base from './base'; import base from './base';
import Config from 'webpack-chain'; import { default as Config } from 'webpack-chain';
// todo: add base configuration for vue // todo: add base configuration for vue
export default function (env) { export default function (env) {
const config = new Config().merge(base(env)); const config = new Config().merge(base(env));
config.module
.rule('vue')
.test(/\.vue$/)
.use('vue-loader')
.loader('vue-loader')
.tap((options) => {
return {
...options,
compiler: 'nativescript-vue-template-compiler',
};
})
.end();
// todo: we may want to use webpack-chain internally // todo: we may want to use webpack-chain internally
// to avoid "trying to read property x of undefined" type of issues // to avoid "trying to read property x of undefined" type of issues
/* /*
@ -14,5 +27,5 @@ export default function (env) {
}); });
*/ */
return {}; return config.toConfig();
} }

View File

@ -19,7 +19,7 @@
"src" "src"
] ]
}, },
"allowSyntheticDefaultImports": true "esModuleInterop": true
}, },
"exclude": [ "exclude": [
"node_modules" "node_modules"