增加wxml解析入口
This commit is contained in:
parent
8330998030
commit
4e8762e6f5
|
|
@ -0,0 +1,13 @@
|
||||||
|
const loaderUtils = require('loader-utils');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} content 文件信息
|
||||||
|
* @param {*} map 文件映射信息
|
||||||
|
* @param {*} meta 模块的元数据
|
||||||
|
*/
|
||||||
|
module.exports = function (content, map, meta) {
|
||||||
|
// const options = loaderUtils.getOptions(this);
|
||||||
|
// console.log(content, options);
|
||||||
|
return content;
|
||||||
|
};
|
||||||
|
|
@ -30,7 +30,7 @@ const relativeFileLoader = (ext = '[ext]') => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const oakLoader = (ext = '[ext]') => {
|
const oakFileLoader = (ext = '[ext]') => {
|
||||||
return {
|
return {
|
||||||
loader: 'file-loader',
|
loader: 'file-loader',
|
||||||
options: {
|
options: {
|
||||||
|
|
@ -38,7 +38,7 @@ const oakLoader = (ext = '[ext]') => {
|
||||||
name: `[path][name].${ext}`,
|
name: `[path][name].${ext}`,
|
||||||
outputPath: (url, resourcePath, context) => {
|
outputPath: (url, resourcePath, context) => {
|
||||||
const outputPath = url.split(
|
const outputPath = url.split(
|
||||||
'oak-general-business/src/platforms/wechatMp/'
|
'oak-general-business/wechatMp/'
|
||||||
)[1];
|
)[1];
|
||||||
return outputPath;
|
return outputPath;
|
||||||
},
|
},
|
||||||
|
|
@ -66,12 +66,20 @@ module.exports = {
|
||||||
'@': SOURCE,
|
'@': SOURCE,
|
||||||
assert: require.resolve('assert'),
|
assert: require.resolve('assert'),
|
||||||
},
|
},
|
||||||
extensions: ['.ts', '.js', 'json'],
|
extensions: ['.ts', '.js'],
|
||||||
symlinks: true,
|
symlinks: true,
|
||||||
fallback: {
|
fallback: {
|
||||||
crypto: require.resolve('crypto-browserify'),
|
crypto: require.resolve('crypto-browserify'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
resolveLoader: {
|
||||||
|
// 第一种使用别名的方式引入自定义的loader
|
||||||
|
alias: {
|
||||||
|
'wxml-loader': path.resolve(__dirname, 'loaders/wxml-loader.js'),
|
||||||
|
},
|
||||||
|
// 第二种方式选查找自己的loaders文件中有没有这个loader再查找node_modules文件
|
||||||
|
// modules: [path.resolve(__dirname, 'loaders'), 'node_modules'],
|
||||||
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
|
@ -87,10 +95,16 @@ module.exports = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.less$/,
|
test: /\.less$/,
|
||||||
include: /oak-general-business/,
|
include: /oak-general-business\/wechatMp/,
|
||||||
|
// include: [
|
||||||
|
// path.resolve(
|
||||||
|
// process.cwd(),
|
||||||
|
// 'node_modules/oak-general-business/wechatMp'
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
type: 'javascript/auto',
|
type: 'javascript/auto',
|
||||||
use: [
|
use: [
|
||||||
oakLoader('wxss'),
|
oakFileLoader('wxss'),
|
||||||
{
|
{
|
||||||
loader: 'less-loader',
|
loader: 'less-loader',
|
||||||
options: {
|
options: {
|
||||||
|
|
@ -118,6 +132,7 @@ module.exports = {
|
||||||
// {
|
// {
|
||||||
// test: /\.json$/,
|
// test: /\.json$/,
|
||||||
// include: /src/,
|
// include: /src/,
|
||||||
|
// exclude: /node_modules/,
|
||||||
// type: 'asset/resource',
|
// type: 'asset/resource',
|
||||||
// generator: {
|
// generator: {
|
||||||
// filename: `[path][name].[ext]`,
|
// filename: `[path][name].[ext]`,
|
||||||
|
|
@ -128,11 +143,34 @@ module.exports = {
|
||||||
{
|
{
|
||||||
test: /\.(xml|wxml)$/,
|
test: /\.(xml|wxml)$/,
|
||||||
include: /src/,
|
include: /src/,
|
||||||
type: 'asset/resource',
|
// type: 'asset/resource',
|
||||||
generator: {
|
// generator: {
|
||||||
filename: `[path][name].[ext]`,
|
// filename: `[path][name].[ext]`,
|
||||||
},
|
// },
|
||||||
// use: [relativeFileLoader('wxml')],
|
type: 'javascript/auto',
|
||||||
|
use: [
|
||||||
|
relativeFileLoader('wxml'),
|
||||||
|
{
|
||||||
|
loader: 'wxml-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(xml|wxml)$/,
|
||||||
|
include: /oak-general-business\/wechatMp/,
|
||||||
|
// include: [
|
||||||
|
// path.resolve(
|
||||||
|
// process.cwd(),
|
||||||
|
// 'node_modules/oak-general-business/wechatMp'
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
type: 'javascript/auto',
|
||||||
|
use: [
|
||||||
|
oakFileLoader('wxml'),
|
||||||
|
{
|
||||||
|
loader: 'wxml-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,3 @@ export interface PackOptionsIgnore {
|
||||||
type: string;
|
type: string;
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @name oak-cli需要输入的参数
|
|
||||||
* @export
|
|
||||||
* @interface OakInput
|
|
||||||
*/
|
|
||||||
export interface OakInput {
|
|
||||||
mode: string;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ function tsConfigJsonContent() {
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./**/*.ts",
|
"./**/*.ts",
|
||||||
"scripts/webpack.js"
|
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^10.0.0",
|
||||||
"globby": "^11.1.0",
|
"globby": "^11.1.0",
|
||||||
"inquirer": "^7.3.3",
|
"inquirer": "^7.3.3",
|
||||||
|
"loader-utils": "^3.2.0",
|
||||||
"mini-css-extract-plugin": "^2.5.3",
|
"mini-css-extract-plugin": "^2.5.3",
|
||||||
"postcss-less": "^6.0.0",
|
"postcss-less": "^6.0.0",
|
||||||
"progress-bar-webpack-plugin": "^2.1.0",
|
"progress-bar-webpack-plugin": "^2.1.0",
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ const requiredPath = require('required-path');
|
||||||
const pluginName = 'OakWeChatMpPlugin';
|
const pluginName = 'OakWeChatMpPlugin';
|
||||||
const OakPagePrefix = '@oak-general-business';
|
const OakPagePrefix = '@oak-general-business';
|
||||||
const OakPagePath = 'node_modules/oak-general-business/wechatMp/';
|
const OakPagePath = 'node_modules/oak-general-business/wechatMp/';
|
||||||
// const oakPagePathRegExp = /node_modules\/oak-general-business\/src\/platforms\/wechatMp\//;
|
|
||||||
|
|
||||||
function getIsOak(str) {
|
function getIsOak(str) {
|
||||||
return str.indexOf(OakPagePrefix) === 0;
|
return str.indexOf(OakPagePrefix) === 0;
|
||||||
|
|
@ -349,7 +348,7 @@ class OakWeChatMpPlugin {
|
||||||
const entries = await globby(patterns, {
|
const entries = await globby(patterns, {
|
||||||
cwd: this.basePath,
|
cwd: this.basePath,
|
||||||
nodir: true,
|
nodir: true,
|
||||||
realpath: false,
|
realpath: true,
|
||||||
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
||||||
dot: false,
|
dot: false,
|
||||||
});
|
});
|
||||||
|
|
@ -370,7 +369,7 @@ class OakWeChatMpPlugin {
|
||||||
{
|
{
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
nodir: true,
|
nodir: true,
|
||||||
realpath: false,
|
realpath: true,
|
||||||
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
||||||
dot: false,
|
dot: false,
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +381,7 @@ class OakWeChatMpPlugin {
|
||||||
{
|
{
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
nodir: true,
|
nodir: true,
|
||||||
realpath: false,
|
realpath: true,
|
||||||
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
ignore: [...extensions.map((ext) => `**/*${ext}`), ...exclude],
|
||||||
dot: false,
|
dot: false,
|
||||||
}
|
}
|
||||||
|
|
@ -504,7 +503,7 @@ class OakWeChatMpPlugin {
|
||||||
const emitAssets = [];
|
const emitAssets = [];
|
||||||
for (let entry of this.assetsEntry) {
|
for (let entry of this.assetsEntry) {
|
||||||
const assets = path.resolve(this.basePath, entry);
|
const assets = path.resolve(this.basePath, entry);
|
||||||
if (/\.(sass|scss|css|less|styl)$/.test(assets)) {
|
if (/\.(sass|scss|css|less|styl|xml)$/.test(assets)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const toTmit = async () => {
|
const toTmit = async () => {
|
||||||
|
|
@ -539,7 +538,7 @@ class OakWeChatMpPlugin {
|
||||||
}
|
}
|
||||||
for (let entry of this.oakAssetsEntry) {
|
for (let entry of this.oakAssetsEntry) {
|
||||||
const assets = path.resolve(process.cwd(), entry);
|
const assets = path.resolve(process.cwd(), entry);
|
||||||
if (/\.(sass|scss|css|less|styl)$/.test(assets)) {
|
if (/\.(sass|scss|css|less|styl|xml)$/.test(assets)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const toTmit = async () => {
|
const toTmit = async () => {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import {
|
||||||
projectConfigContentWithWeChatMp,
|
projectConfigContentWithWeChatMp,
|
||||||
oakConfigContentWithWeChatMp,
|
oakConfigContentWithWeChatMp,
|
||||||
} from './template';
|
} from './template';
|
||||||
import { PromptInput, OakInput } from './interface';
|
import { PromptInput } from './interface';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,4 @@ export interface PackOptions {
|
||||||
export interface PackOptionsIgnore {
|
export interface PackOptionsIgnore {
|
||||||
type: string,
|
type: string,
|
||||||
value: string
|
value: string
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @name oak-cli需要输入的参数
|
|
||||||
* @export
|
|
||||||
* @interface OakInput
|
|
||||||
*/
|
|
||||||
export interface OakInput {
|
|
||||||
mode: string,
|
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +115,6 @@ export function tsConfigJsonContent() {
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./**/*.ts",
|
"./**/*.ts",
|
||||||
"scripts/webpack.js"
|
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue