12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import path from 'path';
- import unpluginVueComponents from 'unplugin-vue-components/webpack';
- import { VantResolver } from 'unplugin-vue-components/resolvers';
- export default function () {
- // this.
- // console.log(this.options);
- // console.log(this.nuxt);
- this.nuxt.hook('build:before', (nuxt, buildOptions) => {
- // console.log(
- // '🚀 ~ file: index.js ~ line 12 ~ this.nuxt.hook ~ buildOptions',
- // ,
- // );
- // console.log(buildOptions.loaders.less);
- buildOptions.loaders.less.lessOptions = {
- modifyVars: {
- // 直接覆盖变量
- // 'text-color': '#111',
- // 'border-color': '#eee',
- hack: `true; @import "${path.resolve(__dirname, 'var.less')}";`,
- },
- };
- // console.log();
- // buildOptions.build.extend
- // console.log(
- // '🚀 ~ file: index.js ~ line 9 ~ this.nuxt.hook ~ buildOptions.build.extend',
- // buildOptions.extend,
- // );
- // buildOptions.extend.push((config, { isClient, loaders: { less } }) => {
- // console.log(less);
- // });
- buildOptions.plugins.push(
- unpluginVueComponents({
- resolvers: [
- VantResolver({
- importStyle: 'less',
- }),
- ],
- }),
- );
- buildOptions.babel.plugins.push([
- 'import',
- {
- libraryName: 'vant',
- libraryDirectory: 'es',
- style: (name) => `${name}/style/less`,
- },
- 'vant',
- ]);
- buildOptions.loaders = buildOptions.loaders ?? {};
- buildOptions.loaders.vue = buildOptions.loaders.vue ?? {};
- buildOptions.loaders.vue.transformAssetUrls =
- buildOptions.loaders.vue.transformAssetUrls ?? {};
- buildOptions.loaders.vue.transformAssetUrls['van-image'] = 'src';
- });
- // this.nuxt.hook('build:before', (nuxt, buildOptions) => {});
- // this.nuxt.hook('webpack:config', (webpackConfigs) => {
- // console.log(
- // '🚀 ~ file: index.js ~ line 17 ~ this.nuxt.hook ~ webpackConfigs',
- // webpackConfigs.module,
- // );
- // });
- // this.nuxt.hook('build:before', (nuxt, buildOptions) => {});
- // this.nuxt.hook('components:dirs', (dirs) => {
- // dirs.push({
- // path: 'vant/es',
- // level: 1,
- // pattern: '*/index.js',
- // ignore: ['utils/index.js'],
- // prefix: 'van',
- // });
- // });
- this.addPlugin(path.resolve(__dirname, 'plugin.js'));
- }
|