diff --git a/packages/taro-cli/src/mini/webpack.ts b/packages/taro-cli/src/mini/webpack.ts index c880b35b0814..a4f44f207bb5 100644 --- a/packages/taro-cli/src/mini/webpack.ts +++ b/packages/taro-cli/src/mini/webpack.ts @@ -29,29 +29,30 @@ export async function build (appPath: string, { watch, adapter = BUILD_TYPES.WEA async function buildWithWebpack ({ appPath }: { appPath: string }, builder) { const { entryFilePath, - outputDir, - sourceDir, buildAdapter, projectConfig, isProduction, - constantsReplaceList + alias } = getBuildData() const miniRunner = await npmProcess.getNpmPkg('@tarojs/mini-runner', appPath) - const babelConfig = getBabelConfig(projectConfig!.plugins!.babel) + const babelConfig = getBabelConfig(projectConfig.babel) const miniRunnerOpts = { entry: { app: entryFilePath }, - sourceDir, - outputDir, + alias, + copy: projectConfig.copy, + outputRoot: projectConfig.outputRoot, buildAdapter, - plugins: { - babel: babelConfig - }, + babel: babelConfig, + csso: projectConfig.csso, + sass: projectConfig.csso, + uglify: projectConfig.uglify, isWatch: !isProduction, - constantsReplaceList, + env: projectConfig.env, + defineConstants: projectConfig.defineConstants, designWidth: projectConfig.designWidth, deviceRatio: projectConfig.deviceRatio } - miniRunner(miniRunnerOpts, builder) + miniRunner(appPath, miniRunnerOpts, builder) } diff --git a/packages/taro-mini-runner/package.json b/packages/taro-mini-runner/package.json index b3ef3b8d5102..d02d84ed4f2c 100644 --- a/packages/taro-mini-runner/package.json +++ b/packages/taro-mini-runner/package.json @@ -1,6 +1,6 @@ { "name": "@tarojs/mini-runner", - "version": "1.3.0-beta.2", + "version": "1.3.1", "description": "Mini app runner for taro", "main": "index.js", "scripts": { @@ -32,8 +32,8 @@ }, "homepage": "https://github.com/NervJS/taro#readme", "dependencies": { - "@tarojs/taro": "1.3.0-beta.2", - "@tarojs/transformer-wx": "1.3.0-beta.2", + "@tarojs/taro": "1.3.1", + "@tarojs/transformer-wx": "1.3.1", "babel-core": "^6.26.3", "babel-generator": "^6.26.1", "babel-loader": "^8.0.6", @@ -43,14 +43,24 @@ "babel-types": "^6.26.0", "better-babel-generator": "^6.26.1", "chalk": "^2.4.2", - "file-loader": "^3.0.1", + "copy-webpack-plugin": "^5.0.3", + "css-loader": "^3.0.0", + "csso-webpack-plugin": "^1.0.0-beta.12", + "file-loader": "^4.0.0", "fs-extra": "^8.0.1", + "less-loader": "^5.0.0", "loader-utils": "^1.2.3", "lodash": "^4.17.11", + "mini-css-extract-plugin": "^0.7.0", "node-sass": "^4.12.0", "ora": "^3.4.0", + "postcss-loader": "^3.0.0", + "postcss-pxtransform": "^1.3.2", "resolve": "^1.11.1", "sass-loader": "^7.1.0", + "stylus-loader": "^3.0.2", + "uglifyjs-webpack-plugin": "^2.1.3", + "url-loader": "^2.0.0", "virtual-module-webpack-plugin": "^0.4.1", "webpack": "^4.31.0", "webpack-chain": "^6.0.0", diff --git a/packages/taro-mini-runner/src/index.ts b/packages/taro-mini-runner/src/index.ts index ea80a3e032e8..9ebb0feffc82 100644 --- a/packages/taro-mini-runner/src/index.ts +++ b/packages/taro-mini-runner/src/index.ts @@ -1,105 +1,32 @@ -import * as path from 'path' import * as webpack from 'webpack' import { IBuildConfig } from './utils/types' import { printBuildError, bindProdLogger } from './utils/logHelper' -import MiniPlugin, { Targets } from './plugins/MiniPlugin' -import { MINI_APP_FILES, BUILD_TYPES } from './utils/constants' +import buildConf from './webpack/build.conf' -const extensions = ['.ts', '.tsx', '.js', '.jsx'] - -const globalObjectMap = { - [BUILD_TYPES.WEAPP]: 'wx', - [BUILD_TYPES.ALIPAY]: 'my', - [BUILD_TYPES.SWAN]: 'swan', - [BUILD_TYPES.QQ]: 'qq', - [BUILD_TYPES.TT]: 'tt' +const customizeChain = (chain, customizeFunc: Function) => { + if (customizeFunc instanceof Function) { + customizeFunc(chain, webpack) + } } -export default function build (config: IBuildConfig) { - const compilePlugins = config.plugins - const { babel } = compilePlugins - const webpackConfig = { - mode: config.isWatch ? 'development' : 'production', - devtool: false, - entry: config.entry, - output: { - filename: '[name].js', - publicPath: '/', - path: config.outputDir, - globalObject: globalObjectMap[config.buildAdapter] - }, - resolve: { - extensions - }, - target: Targets[config.buildAdapter], - optimization: { - runtimeChunk: { - name: 'runtime' - }, - splitChunks: { - chunks: 'all', - maxInitialRequests: Infinity, - minSize: 0, - name: 'vendors' - } - }, - module: { - rules: [ - { - test: /\.(tsx?|jsx?)$/, - use: [{ - loader: path.resolve(__dirname, './loaders/fileParseLoader'), - options: { - babel, - designWidth: config.designWidth, - deviceRatio: config.deviceRatio, - buildAdapter: config.buildAdapter, - constantsReplaceList: config.constantsReplaceList - } - }, { - loader: path.resolve(__dirname, './loaders/wxTransformerLoader'), - options: { - buildAdapter: config.buildAdapter - } - }] - }, - { - test: /\.(scss|wxss|acss|ttss|acss|)$/, - include: /src/, - use: [ - { - loader: require.resolve('file-loader'), - options: { - useRelativePath: true, - name: `[path][name]${MINI_APP_FILES[config.buildAdapter].STYLE}`, - context: config.sourceDir - } - }, - { - loader: require.resolve('sass-loader'), - options: { +export default function build (appPath: string, config: IBuildConfig, mainBuilder) { + const mode = 'development' + return new Promise((resolve, reject) => { + const webpackChain = buildConf(appPath, mode, config) - }, - }, - ], - } - ] - }, - plugins: [ - new MiniPlugin({ - buildAdapter: config.buildAdapter, - constantsReplaceList: config.constantsReplaceList - }) - ] - } + customizeChain(webpackChain, config.webpackChain) + const webpackConfig = webpackChain.toConfig() - const compiler = webpack(webpackConfig) - bindProdLogger(compiler) + const compiler = webpack(webpackConfig) + bindProdLogger(compiler) - compiler.run((err) => { - if (err) { - printBuildError(err) - } + compiler.run((err) => { + if (err) { + printBuildError(err); + return reject(err) + } + resolve() + }) }) } diff --git a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts index 9b69760411fc..c7b93a1a6b02 100644 --- a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts +++ b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts @@ -176,13 +176,11 @@ export default class MiniPlugin { } const { entry } = compiler.options function getEntryPath (entry) { - if (Array.isArray(entry)) { - return entry.map(item => getEntryPath[item]).find(item => item) + const app = entry['app'] + if (Array.isArray(app)) { + return app[0] } - if (typeof entry === 'object') { - return entry['app'] - } - return entry + return app } const appEntryPath = getEntryPath(entry) this.sourceDir = path.dirname(appEntryPath) diff --git a/packages/taro-mini-runner/src/utils/constants.ts b/packages/taro-mini-runner/src/utils/constants.ts index 2224d8cc9749..2dcdedbba06e 100644 --- a/packages/taro-mini-runner/src/utils/constants.ts +++ b/packages/taro-mini-runner/src/utils/constants.ts @@ -7,7 +7,15 @@ export const TS_EXT: string[] = ['.ts', '.tsx'] export const REG_SCRIPT: RegExp = /\.(js|jsx)(\?.*)?$/ export const REG_TYPESCRIPT: RegExp = /\.(tsx|ts)(\?.*)?$/ -export const REG_SCRIPTS: RegExp = /\.[tj]sx?$/i +export const REG_SCRIPTS: RegExp = /\.[tj]sx?$/ +export const REG_SASS: RegExp = /\.(s[ac]ss)$/ +export const REG_LESS: RegExp = /\.less$/ +export const REG_STYLUS: RegExp = /\.styl$/ +export const REG_STYLE: RegExp = /\.(css|scss|sass|less|styl|wxss)(\?.*)?$/ +export const REG_MEDIA: RegExp = /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/ +export const REG_IMAGE: RegExp = /\.(png|jpe?g|gif|bpm|svg|webp)(\?.*)?$/ +export const REG_FONT: RegExp = /\.(woff2?|eot|ttf|otf)(\?.*)?$/ +export const REG_JSON: RegExp = /\.json(\?.*)?$/ export const NODE_MODULES = 'node_modules' export const NODE_MODULES_REG = /(.*)node_modules/ diff --git a/packages/taro-mini-runner/src/utils/index.ts b/packages/taro-mini-runner/src/utils/index.ts index 8e12acf4cf68..4f55a21a9b88 100644 --- a/packages/taro-mini-runner/src/utils/index.ts +++ b/packages/taro-mini-runner/src/utils/index.ts @@ -3,10 +3,13 @@ import * as fs from 'fs-extra' import * as resolvePath from 'resolve' import * as t from 'babel-types' +import { mergeWith } from 'lodash' import { CONFIG_MAP, JS_EXT, TS_EXT, NODE_MODULES_REG } from './constants' import { IOption, IComponentObj } from './types' +export const isNodeModule = (filename: string) => NODE_MODULES_REG.test(filename) + export function isNpmPkg (name: string): boolean { if (/^(\.|\/)/.test(name)) { return false @@ -173,3 +176,17 @@ export function resolveNpmSync (pkgName: string, root): string | null { return null } } + +export function recursiveMerge (src, ...args) { + return mergeWith(src, ...args, (value, srcValue) => { + const typeValue = typeof value + const typeSrcValue = typeof srcValue + if (typeValue !== typeSrcValue) return + if (Array.isArray(value) && Array.isArray(srcValue)) { + return value.concat(srcValue) + } + if (typeValue === 'object') { + return recursiveMerge(value, srcValue) + } + }) +} diff --git a/packages/taro-mini-runner/src/utils/types.ts b/packages/taro-mini-runner/src/utils/types.ts index 85088955d277..3877945c277a 100644 --- a/packages/taro-mini-runner/src/utils/types.ts +++ b/packages/taro-mini-runner/src/utils/types.ts @@ -37,16 +37,35 @@ export interface IChain { [key: string]: any } -export interface ITaroMiniConfig { - entry: webpack.Entry - output: webpack.Output, - buildAdapter: BUILD_TYPES +export interface ICopyOptions { + patterns: { + from: string + to: string + ignore: string[] + }[] + options: { + ignore: string[] + } } -export interface ITaroPlugins { - babel: IOption - csso?: TogglableOptions - uglify?: TogglableOptions +export interface ITaroMiniConfig { + webpackChain: (chain: any, webpack: any) => void + alias: IOption + entry: webpack.Entry + output: webpack.Output + enableSourceMap: boolean + + cssLoaderOption: IOption + styleLoaderOption: IOption + sassLoaderOption: IOption + lessLoaderOption: IOption + stylusLoaderOption: IOption + mediaUrlLoaderOption: IOption + fontUrlLoaderOption: IOption + imageUrlLoaderOption: IOption + esnextModules: string[] + + postcss?: IPostcssOption } export interface ICopyOptions { @@ -61,9 +80,7 @@ export interface ICopyOptions { } export interface ITaroBaseConfig { - outputDir: string - staticDirectory: string - chunkDirectory: string + outputRoot: string copy: ICopyOptions designWidth: number @@ -72,10 +89,14 @@ export interface ITaroBaseConfig { defineConstants?: IOption env?: IOption - plugins: ITaroPlugins + babel: IOption + csso?: TogglableOptions + uglify?: TogglableOptions, + sass?: IOption } export interface IBuildConfig extends ITaroBaseConfig, ITaroMiniConfig { isWatch: boolean, - constantsReplaceList: IOption + port?: number, + buildAdapter: BUILD_TYPES } diff --git a/packages/taro-mini-runner/src/webpack/build.conf.ts b/packages/taro-mini-runner/src/webpack/build.conf.ts new file mode 100644 index 000000000000..469f19d12f33 --- /dev/null +++ b/packages/taro-mini-runner/src/webpack/build.conf.ts @@ -0,0 +1,143 @@ +import * as path from 'path' +import * as Chain from 'webpack-chain' + +import { IBuildConfig } from '../utils/types' +import { + getCopyWebpackPlugin, + getDefinePlugin, + processEnvOption, + getCssoWebpackPlugin, + getUglifyPlugin, + getDevtool, + getOutput, + getModule, + mergeOption, + getMiniPlugin +} from './chain' +import { BUILD_TYPES } from '../utils/constants' +import { Targets } from '../plugins/MiniPlugin' + +const emptyObj = {} + +export default (appPath: string, mode, config: Partial): any => { + const chain = new Chain() + const { + buildAdapter = BUILD_TYPES.WEAPP, + alias = emptyObj, + copy, + entry = emptyObj, + output = emptyObj, + outputRoot = 'dist', + + designWidth = 750, + deviceRatio, + enableSourceMap = false, + + defineConstants = emptyObj, + env = emptyObj, + cssLoaderOption = emptyObj, + sassLoaderOption = emptyObj, + lessLoaderOption = emptyObj, + stylusLoaderOption = emptyObj, + mediaUrlLoaderOption = emptyObj, + fontUrlLoaderOption = emptyObj, + imageUrlLoaderOption = emptyObj, + + postcss = emptyObj, + + babel, + csso, + uglify + } = config + + const plugin: any = {} + const minimizer: any[] = [] + + if (copy) { + plugin.copyWebpackPlugin = getCopyWebpackPlugin({ copy, appPath }) + } + const constantsReplaceList = mergeOption([processEnvOption(env), defineConstants]) + plugin.definePlugin = getDefinePlugin([constantsReplaceList]) + plugin.miniPlugin = getMiniPlugin({ buildAdapter, constantsReplaceList }) + + const isCssoEnabled = (csso && csso.enable === false) + ? false + : true + + + const isUglifyEnabled = (uglify && uglify.enable === false) + ? false + : true + + if (mode === 'production') { + if (isUglifyEnabled) { + minimizer.push(getUglifyPlugin([ + enableSourceMap, + uglify ? uglify.config : {} + ])) + } + + if (isCssoEnabled) { + plugin.cssoWebpackPlugin = getCssoWebpackPlugin([csso ? csso.config : {}]) + } + } + + chain.merge({ + mode, + devtool: getDevtool(enableSourceMap), + entry, + output: getOutput(appPath, [{ + outputRoot, + publicPath: '/', + buildAdapter + }, output]), + target: Targets[buildAdapter], + resolve: { + alias, + extensions: ['.js', '.jsx', '.ts', '.tsx'], + mainFields: ['main', 'module'], + symlinks: true, + modules: [ + path.join(appPath, 'node_modules'), + 'node_modules' + ] + }, + resolveLoader: { + modules: [ + 'node_modules' + ] + }, + module: getModule(appPath, { + buildAdapter, + constantsReplaceList, + designWidth, + deviceRatio, + enableSourceMap, + + cssLoaderOption, + lessLoaderOption, + sassLoaderOption, + stylusLoaderOption, + fontUrlLoaderOption, + imageUrlLoaderOption, + mediaUrlLoaderOption, + + postcss, + babel + }), + plugin, + optimization: { + minimizer, + runtimeChunk: { + name: 'runtime' + }, + splitChunks: { + chunks: 'all', + maxInitialRequests: Infinity, + minSize: 0, + name: 'vendors' + } + } + }) + return chain +} diff --git a/packages/taro-mini-runner/src/webpack/chain.ts b/packages/taro-mini-runner/src/webpack/chain.ts new file mode 100644 index 000000000000..d438c7b398d3 --- /dev/null +++ b/packages/taro-mini-runner/src/webpack/chain.ts @@ -0,0 +1,321 @@ +import * as path from 'path' + +import * as CopyWebpackPlugin from 'copy-webpack-plugin' +import CssoWebpackPlugin from 'csso-webpack-plugin' +import * as sass from 'node-sass' +import { partial } from 'lodash' +import { mapKeys, pipe } from 'lodash/fp' +import * as UglifyJsPlugin from 'uglifyjs-webpack-plugin' +import * as webpack from 'webpack' + +import { getPostcssPlugins } from './postcss.conf' + +import MiniPlugin from '../plugins/MiniPlugin' +import { PostcssOption, IOption, ICopyOptions, IPostcssOption } from '../utils/types' +import { recursiveMerge, isNodeModule } from '../utils' +import { REG_SASS, REG_LESS, REG_STYLUS, REG_STYLE, REG_MEDIA, REG_FONT, REG_IMAGE, BUILD_TYPES, REG_SCRIPTS, MINI_APP_FILES } from '../utils/constants' + +const globalObjectMap = { + [BUILD_TYPES.WEAPP]: 'wx', + [BUILD_TYPES.ALIPAY]: 'my', + [BUILD_TYPES.SWAN]: 'swan', + [BUILD_TYPES.QQ]: 'qq', + [BUILD_TYPES.TT]: 'tt' +} + +const defaultUglifyJsOption = { + keep_fnames: true, + output: { + comments: false, + keep_quoted_props: true, + quote_keys: true, + beautify: false + }, + warnings: false +} +const defaultCSSCompressOption = { + mergeRules: false, + mergeIdents: false, + reduceIdents: false, + discardUnused: false, + minifySelectors: false +} + +const defaultMediaUrlLoaderOption = { + limit: 10240 +} +const defaultFontUrlLoaderOption = { + limit: 10240 +} +const defaultImageUrlLoaderOption = { + limit: 10240 +} +const defaultCssModuleOption: PostcssOption.cssModules = { + enable: false, + config: { + namingPattern: 'global', + generateScopedName: '[name]__[local]___[hash:base64:5]' + } +} + +const getLoader = (loaderName: string, options: IOption) => { + return { + loader: require.resolve(loaderName), + options: options || {} + } +} + +const listify = listOrItem => { + if (Array.isArray(listOrItem)) { + return listOrItem + } + return [listOrItem] +} + +const getPlugin = (plugin: any, args: IOption[]) => { + return { + plugin, + args + } +} + +export const mergeOption = ([...options]: IOption[]): IOption => { + return recursiveMerge({}, ...options) +} + +const styleModuleReg = /(.*\.module).*\.(css|s[ac]ss|less|styl)\b/ +const styleGlobalReg = /(.*\.global).*\.(css|s[ac]ss|less|styl)\b/ + +export const processEnvOption = partial(mapKeys, (key: string) => `process.env.${key}`) + +export const getCssLoader = pipe(mergeOption, partial(getLoader, 'css-loader')) +export const getPostcssLoader = pipe(mergeOption, partial(getLoader, 'postcss-loader')) +export const getSassLoader = pipe(mergeOption, partial(getLoader, 'sass-loader')) +export const getLessLoader = pipe(mergeOption, partial(getLoader, 'less-loader')) +export const getStylusLoader = pipe(mergeOption, partial(getLoader, 'stylus-loader')) +export const getUrlLoader = pipe(mergeOption, partial(getLoader, 'url-loader')) +export const getFileLoader = pipe(mergeOption, partial(getLoader, 'file-loader')) +export const getFileParseLoader = pipe(mergeOption, partial(getLoader, path.resolve(__dirname, '../loaders/fileParseLoader'))) +export const getWxTransformerLoader = pipe(mergeOption, partial(getLoader, path.resolve(__dirname, '../loaders/wxTransformerLoader'))) + +export const getDefinePlugin = pipe(mergeOption, listify, partial(getPlugin, webpack.DefinePlugin)) +export const getUglifyPlugin = ([enableSourceMap, uglifyOptions]) => { + return new UglifyJsPlugin({ + cache: true, + parallel: true, + sourceMap: enableSourceMap, + uglifyOptions: recursiveMerge({}, defaultUglifyJsOption, uglifyOptions) + }) +} +export const getCssoWebpackPlugin = ([cssoOption]) => { + return pipe(mergeOption, listify, partial(getPlugin, CssoWebpackPlugin))([defaultCSSCompressOption, cssoOption]) +} +export const getCopyWebpackPlugin = ({ copy, appPath }: { + copy: ICopyOptions, + appPath: string +}) => { + const args = [ + copy.patterns.map(({ from, to }) => { + return { + from, + to: path.resolve(appPath, to), + context: appPath + } + }), + copy.options + ] + return partial(getPlugin, CopyWebpackPlugin)(args) +} + +export const getMiniPlugin = (args) => { + return partial(getPlugin, MiniPlugin)([args]) +} + +export const getModule = (appPath: string, { + designWidth, + deviceRatio, + buildAdapter, + constantsReplaceList, + enableSourceMap, + + cssLoaderOption, + lessLoaderOption, + sassLoaderOption, + stylusLoaderOption, + fontUrlLoaderOption, + imageUrlLoaderOption, + mediaUrlLoaderOption, + postcss, + + babel +}) => { + const postcssOption: IPostcssOption = postcss || {} + + const cssModuleOptions: PostcssOption.cssModules = recursiveMerge({}, defaultCssModuleOption, postcssOption.cssModules) + + const { namingPattern, generateScopedName } = cssModuleOptions.config! + + const cssOptions = [ + { + importLoaders: 1, + sourceMap: enableSourceMap, + modules: false + }, + cssLoaderOption + ] + const cssOptionsWithModule = [ + Object.assign( + { + importLoaders: 1, + sourceMap: enableSourceMap, + modules: namingPattern === 'module' ? true : 'global' + }, + typeof generateScopedName === 'function' + ? { getLocalIdent: (context, _, localName) => generateScopedName(localName, context.resourcePath) } + : { localIdentName: generateScopedName } + ), + cssLoaderOption + ] + + const cssLoader = getCssLoader(cssOptions) + const cssLoaders: { + include?; + use; + }[] = [{ + use: [cssLoader] + }] + + if (cssModuleOptions.enable) { + const cssLoaderWithModule = getCssLoader(cssOptionsWithModule) + let cssModuleCondition + + if (cssModuleOptions.config!.namingPattern === 'module') { + /* 不排除 node_modules 内的样式 */ + cssModuleCondition = styleModuleReg + } else { + cssModuleCondition = { + and: [ + { exclude: styleGlobalReg }, + { exclude: [isNodeModule] } + ] + } + } + cssLoaders.unshift({ + include: [cssModuleCondition], + use: [cssLoaderWithModule] + }) + } + + const postcssLoader = getPostcssLoader([ + { sourceMap: enableSourceMap }, + { + ident: 'postcss', + plugins: getPostcssPlugins(appPath, { + designWidth, + deviceRatio, + postcssOption + }) + } + ]) + const sassLoader = getSassLoader([{ + sourceMap: true, + implementation: sass + }, sassLoaderOption]) + const lessLoader = getLessLoader([{ sourceMap: enableSourceMap }, lessLoaderOption]) + + const stylusLoader = getStylusLoader([{ sourceMap: enableSourceMap }, stylusLoaderOption]) + + const fileLoader = getFileLoader([{ + useRelativePath: true, + name: `[path][name]${MINI_APP_FILES[buildAdapter].STYLE}` + }]) + + const fileParseLoader = getFileParseLoader([{ + babel, + designWidth, + deviceRatio, + buildAdapter, + constantsReplaceList + }]) + + const wxTransformerLoader = getWxTransformerLoader([{ + buildAdapter + }]) + + const rule = { + sass: { + test: REG_SASS, + enforce: 'pre', + use: [sassLoader] + }, + less: { + test: REG_LESS, + enforce: 'pre', + use: [lessLoader] + }, + stylus: { + test: REG_STYLUS, + enforce: 'pre', + use: [stylusLoader] + }, + // css: { + // test: REG_STYLE, + // oneOf: cssLoaders + // }, + styleFiles: { + test: REG_STYLE, + use: [fileLoader] + }, + postcss: { + test: REG_STYLE, + use: [postcssLoader] + }, + script: { + test: REG_SCRIPTS, + use: [fileParseLoader, wxTransformerLoader], + }, + media: { + test: REG_MEDIA, + use: { + urlLoader: getUrlLoader([defaultMediaUrlLoaderOption, { + name: `[path][name].[ext]`, + ...mediaUrlLoaderOption + }]) + } + }, + font: { + test: REG_FONT, + use: { + urlLoader: getUrlLoader([defaultFontUrlLoaderOption, { + name: `[path][name].[ext]`, + ...fontUrlLoaderOption + }]) + } + }, + image: { + test: REG_IMAGE, + use: { + urlLoader: getUrlLoader([defaultImageUrlLoaderOption, { + name: `[path][name].[ext]`, + ...imageUrlLoaderOption + }]) + } + } + } + + return { rule } +} + +export function getOutput (appPath: string, [{ outputRoot, publicPath, buildAdapter }, customOutput]) { + return { + path: path.join(appPath, outputRoot), + publicPath, + filename: '[name].js', + globalObject: globalObjectMap[buildAdapter], + ...customOutput + } +} + +export function getDevtool (enableSourceMap) { + return enableSourceMap ? 'cheap-module-eval-source-map' : 'none' +} diff --git a/packages/taro-mini-runner/src/webpack/postcss.conf.ts b/packages/taro-mini-runner/src/webpack/postcss.conf.ts new file mode 100644 index 000000000000..6ae056e0ba55 --- /dev/null +++ b/packages/taro-mini-runner/src/webpack/postcss.conf.ts @@ -0,0 +1,74 @@ +import * as path from 'path' + +import * as autoprefixer from 'autoprefixer' +import * as pxtransform from 'postcss-pxtransform' +import { sync as resolveSync } from 'resolve' + +import { isNpmPkg, recursiveMerge } from '../utils' +import { IPostcssOption } from '../utils/types' +import browserList from '../config/browser_list' + +const defaultAutoprefixerOption = { + enable: true, + config: { + browsers: browserList, + flexbox: 'no-2009' + } +} +const defaultPxtransformOption: { + [key: string]: any +} = { + enable: true, + config: { + platform: 'weapp' + } +} + +const optionsWithDefaults = ['autoprefixer', 'pxtransform', 'cssModules'] + +const plugins = [] as any[] + +export const getPostcssPlugins = function (appPath: string, { + designWidth, + deviceRatio, + postcssOption = {} as IPostcssOption +}) { + + if (designWidth) { + defaultPxtransformOption.config.designWidth = designWidth + } + + if (deviceRatio) { + defaultPxtransformOption.config.deviceRatio = deviceRatio + } + + const autoprefixerOption = recursiveMerge({}, defaultAutoprefixerOption, postcssOption.autoprefixer) + const pxtransformOption = recursiveMerge({}, defaultPxtransformOption, postcssOption.pxtransform) + + if (autoprefixerOption.enable) { + plugins.push(autoprefixer(autoprefixerOption.config)) + } + + if (pxtransformOption.enable) { + plugins.push(pxtransform(pxtransformOption.config)) + } + + Object.entries(postcssOption).forEach(([pluginName, pluginOption]) => { + if (optionsWithDefaults.indexOf(pluginName) > -1) return + if (!pluginOption || !pluginOption.enable) return + + if (!isNpmPkg(pluginName)) { // local plugin + pluginName = path.join(appPath, pluginName) + } + + try { + const pluginPath = resolveSync(pluginName, { basedir: appPath }) + plugins.push(require(pluginPath)(pluginOption.config || {})) + } catch (e) { + const msg = e.code === 'MODULE_NOT_FOUND' ? `缺少postcss插件${pluginName}, 已忽略` : e + console.log(msg) + } + }) + + return plugins +} diff --git a/packages/taro-mini-runner/yarn.lock b/packages/taro-mini-runner/yarn.lock index 262bd904eee0..b5d99f892ca8 100644 --- a/packages/taro-mini-runner/yarn.lock +++ b/packages/taro-mini-runner/yarn.lock @@ -713,6 +713,10 @@ amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" +ansi-colors@^3.0.0: + version "3.2.4" + resolved "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf" + ansi-escapes@^3.0.0: version "3.2.0" resolved "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" @@ -802,6 +806,16 @@ array-reduce@~0.0.0: version "0.0.0" resolved "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b" +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + array-unique@^0.3.2: version "0.3.2" resolved "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" @@ -851,6 +865,12 @@ async-limiter@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" +async@^2.5.0: + version "2.6.2" + resolved "https://registry.npmjs.org/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" + dependencies: + lodash "^4.17.11" + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -1244,6 +1264,10 @@ bluebird@^3.5.3: version "3.5.4" resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.5.4.tgz#d6cc661595de30d5b3af5fcedd3c0b3ef6ec5714" +bluebird@^3.5.5: + version "3.5.5" + resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f" + bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: version "4.11.8" resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" @@ -1388,6 +1412,25 @@ cacache@^11.0.2: unique-filename "^1.1.1" y18n "^4.0.0" +cacache@^11.3.2: + version "11.3.3" + resolved "https://registry.npmjs.org/cacache/-/cacache-11.3.3.tgz#8bd29df8c6a718a6ebd2d010da4d7972ae3bbadc" + dependencies: + bluebird "^3.5.5" + chownr "^1.1.1" + figgy-pudding "^3.5.1" + glob "^7.1.4" + graceful-fs "^4.1.15" + lru-cache "^5.1.1" + mississippi "^3.0.0" + mkdirp "^0.5.1" + move-concurrently "^1.0.1" + promise-inflight "^1.0.1" + rimraf "^2.6.3" + ssri "^6.0.1" + unique-filename "^1.1.1" + y18n "^4.0.0" + cache-base@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" @@ -1402,16 +1445,32 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +caller-callsite@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz#847e0fce0a223750a9a027c54b33731ad3154134" + dependencies: + callsites "^2.0.0" + caller-path@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" dependencies: callsites "^0.2.0" +caller-path@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz#468f83044e369ab2010fac5f06ceee15bb2cb1f4" + dependencies: + caller-callsite "^2.0.0" + callsites@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" +callsites@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1435,7 +1494,7 @@ camelcase@^4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" -camelcase@^5.0.0: +camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -1566,6 +1625,10 @@ clone@^1.0.2: version "1.0.4" resolved "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" +clone@^2.1.1: + version "2.1.2" + resolved "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" + co@^4.6.0: version "4.6.0" resolved "https://registry.npmjs.org/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -1657,6 +1720,23 @@ copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" +copy-webpack-plugin@^5.0.3: + version "5.0.3" + resolved "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-5.0.3.tgz#2179e3c8fd69f13afe74da338896f1f01a875b5c" + dependencies: + cacache "^11.3.2" + find-cache-dir "^2.1.0" + glob-parent "^3.1.0" + globby "^7.1.1" + is-glob "^4.0.1" + loader-utils "^1.2.3" + minimatch "^3.0.4" + normalize-path "^3.0.0" + p-limit "^2.2.0" + schema-utils "^1.0.0" + serialize-javascript "^1.7.0" + webpack-log "^2.0.0" + core-js@^2.4.0, core-js@^2.5.0: version "2.6.5" resolved "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895" @@ -1665,6 +1745,15 @@ core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" +cosmiconfig@^5.0.0: + version "5.2.1" + resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a" + dependencies: + import-fresh "^2.0.0" + is-directory "^0.3.1" + js-yaml "^3.13.1" + parse-json "^4.0.0" + create-ecdh@^4.0.0: version "4.0.3" resolved "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" @@ -1734,6 +1823,49 @@ crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" +css-loader@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/css-loader/-/css-loader-3.0.0.tgz#bdd48a4921eefedf1f0a55266585944d4e5efc63" + dependencies: + camelcase "^5.3.1" + cssesc "^3.0.0" + icss-utils "^4.1.1" + loader-utils "^1.2.3" + normalize-path "^3.0.0" + postcss "^7.0.17" + postcss-modules-extract-imports "^2.0.0" + postcss-modules-local-by-default "^3.0.2" + postcss-modules-scope "^2.1.0" + postcss-modules-values "^3.0.0" + postcss-value-parser "^4.0.0" + schema-utils "^1.0.0" + +css-tree@1.0.0-alpha.29: + version "1.0.0-alpha.29" + resolved "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.29.tgz#3fa9d4ef3142cbd1c301e7664c1f352bd82f5a39" + dependencies: + mdn-data "~1.1.0" + source-map "^0.5.3" + +cssesc@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" + +csso-webpack-plugin@^1.0.0-beta.12: + version "1.0.0-beta.12" + resolved "https://registry.npmjs.org/csso-webpack-plugin/-/csso-webpack-plugin-1.0.0-beta.12.tgz#a42d02f74043eb8e7f303c9ba27bbb65c78972b8" + dependencies: + async "^2.5.0" + csso "^3.4.0" + source-map "^0.6.1" + webpack-sources "^1.0.1" + +csso@^3.4.0: + version "3.5.1" + resolved "https://registry.npmjs.org/csso/-/csso-3.5.1.tgz#7b9eb8be61628973c1b261e169d2f024008e758b" + dependencies: + css-tree "1.0.0-alpha.29" + cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0": version "0.3.6" resolved "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz#f85206cee04efa841f3c5982a74ba96ab20d65ad" @@ -1882,6 +2014,12 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +dir-glob@^2.0.0: + version "2.2.2" + resolved "https://registry.npmjs.org/dir-glob/-/dir-glob-2.2.2.tgz#fa09f0694153c8918b18ba0deafae94769fc50c4" + dependencies: + path-type "^3.0.0" + doctrine@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" @@ -2247,11 +2385,11 @@ file-entry-cache@^2.0.0: flat-cache "^1.2.1" object-assign "^4.0.1" -file-loader@^3.0.1: - version "3.0.1" - resolved "https://registry.npmjs.org/file-loader/-/file-loader-3.0.1.tgz#f8e0ba0b599918b51adfe45d66d1e771ad560faa" +file-loader@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/file-loader/-/file-loader-4.0.0.tgz#c3570783fefb6e1bc0978a856f4bf5825b966c2a" dependencies: - loader-utils "^1.0.2" + loader-utils "^1.2.2" schema-utils "^1.0.0" fill-range@^4.0.0: @@ -2263,7 +2401,7 @@ fill-range@^4.0.0: repeat-string "^1.6.1" to-regex-range "^2.1.0" -find-cache-dir@^2.0.0: +find-cache-dir@^2.0.0, find-cache-dir@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" dependencies: @@ -2440,7 +2578,7 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@~7.1.1: +glob@^7.0.0, glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@~7.1.1: version "7.1.4" resolved "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" dependencies: @@ -2459,6 +2597,17 @@ globals@^9.18.0: version "9.18.0" resolved "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" +globby@^7.1.1: + version "7.1.1" + resolved "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz#fb2ccff9401f8600945dfada97440cca972b8680" + dependencies: + array-union "^1.0.1" + dir-glob "^2.0.0" + glob "^7.1.2" + ignore "^3.3.5" + pify "^3.0.0" + slash "^1.0.0" + globule@^1.0.0: version "1.2.1" resolved "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz#5dffb1b191f22d20797a9369b49eab4e9839696d" @@ -2502,6 +2651,10 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -2610,6 +2763,12 @@ iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.4: dependencies: safer-buffer ">= 2.1.2 < 3" +icss-utils@^4.0.0, icss-utils@^4.1.1: + version "4.1.1" + resolved "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467" + dependencies: + postcss "^7.0.14" + ieee754@^1.1.4: version "1.1.13" resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" @@ -2624,10 +2783,29 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" -ignore@^3.3.3: +ignore@^3.3.3, ignore@^3.3.5: version "3.3.10" resolved "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" +import-cwd@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9" + dependencies: + import-from "^2.1.0" + +import-fresh@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" + dependencies: + caller-path "^2.0.0" + resolve-from "^3.0.0" + +import-from@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/import-from/-/import-from-2.1.0.tgz#335db7f2a7affd53aaa471d4b8021dee36b7f3b1" + dependencies: + resolve-from "^3.0.0" + import-local@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" @@ -2649,6 +2827,10 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" +indexes-of@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607" + indexof@0.0.1: version "0.0.1" resolved "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" @@ -2773,6 +2955,10 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-data-descriptor "^1.0.0" kind-of "^6.0.2" +is-directory@^0.3.1: + version "0.3.1" + resolved "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" + is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -2813,7 +2999,7 @@ is-glob@^3.1.0: dependencies: is-extglob "^2.1.0" -is-glob@^4.0.0: +is-glob@^4.0.0, is-glob@^4.0.1: version "4.0.1" resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" dependencies: @@ -2825,6 +3011,10 @@ is-number@^3.0.0: dependencies: kind-of "^3.0.2" +is-plain-obj@^1.0.0: + version "1.1.0" + resolved "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" @@ -3261,7 +3451,7 @@ jest@^24.8.0: import-local "^2.0.0" jest-cli "^24.8.0" -js-base64@^2.1.8: +js-base64@^2.1.8, js-base64@^2.1.9: version "2.5.1" resolved "https://registry.npmjs.org/js-base64/-/js-base64-2.5.1.tgz#1efa39ef2c5f7980bb1784ade4a8af2de3291121" @@ -3273,7 +3463,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "4.0.0" resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" -js-yaml@^3.9.1: +js-yaml@^3.13.1, js-yaml@^3.9.1: version "3.13.1" resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" dependencies: @@ -3432,6 +3622,14 @@ left-pad@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e" +less-loader@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/less-loader/-/less-loader-5.0.0.tgz#498dde3a6c6c4f887458ee9ed3f086a12ad1b466" + dependencies: + clone "^2.1.1" + loader-utils "^1.1.0" + pify "^4.0.1" + leven@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" @@ -3466,7 +3664,7 @@ loader-runner@^2.3.0: version "2.4.0" resolved "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" -loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.3: +loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2.2, loader-utils@^1.2.3: version "1.2.3" resolved "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7" dependencies: @@ -3481,6 +3679,10 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + lodash.some@^4.6.0: version "4.6.0" resolved "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" @@ -3578,6 +3780,10 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" +mdn-data@~1.1.0: + version "1.1.4" + resolved "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz#50b5d4ffc4575276573c4eedb8780812a8419f01" + mem@^4.0.0: version "4.3.0" resolved "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178" @@ -3653,6 +3859,10 @@ mime-types@^2.1.12, mime-types@~2.1.19: dependencies: mime-db "1.40.0" +mime@^2.0.3: + version "2.4.4" + resolved "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5" + mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" @@ -3661,6 +3871,15 @@ mimic-fn@^2.0.0: version "2.1.0" resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" +mini-css-extract-plugin@^0.7.0: + version "0.7.0" + resolved "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.7.0.tgz#5ba8290fbb4179a43dd27cca444ba150bee743a0" + dependencies: + loader-utils "^1.1.0" + normalize-url "1.9.1" + schema-utils "^1.0.0" + webpack-sources "^1.1.0" + minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -3934,6 +4153,15 @@ normalize-path@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" +normalize-url@1.9.1: + version "1.9.1" + resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-1.9.1.tgz#2cc0d66b31ea23036458436e3620d85954c66c3c" + dependencies: + object-assign "^4.0.1" + prepend-http "^1.0.0" + query-string "^4.1.0" + sort-keys "^1.0.0" + npm-bundled@^1.0.1: version "1.0.6" resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd" @@ -4113,7 +4341,7 @@ p-is-promise@^2.0.0: version "2.1.0" resolved "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" -p-limit@^2.0.0: +p-limit@^2.0.0, p-limit@^2.2.0: version "2.2.0" resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" dependencies: @@ -4293,10 +4521,110 @@ posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" +postcss-load-config@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-2.1.0.tgz#c84d692b7bb7b41ddced94ee62e8ab31b417b003" + dependencies: + cosmiconfig "^5.0.0" + import-cwd "^2.0.0" + +postcss-loader@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/postcss-loader/-/postcss-loader-3.0.0.tgz#6b97943e47c72d845fa9e03f273773d4e8dd6c2d" + dependencies: + loader-utils "^1.1.0" + postcss "^7.0.0" + postcss-load-config "^2.0.0" + schema-utils "^1.0.0" + +postcss-modules-extract-imports@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz#818719a1ae1da325f9832446b01136eeb493cd7e" + dependencies: + postcss "^7.0.5" + +postcss-modules-local-by-default@^3.0.2: + version "3.0.2" + resolved "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.2.tgz#e8a6561be914aaf3c052876377524ca90dbb7915" + dependencies: + icss-utils "^4.1.1" + postcss "^7.0.16" + postcss-selector-parser "^6.0.2" + postcss-value-parser "^4.0.0" + +postcss-modules-scope@^2.1.0: + version "2.1.0" + resolved "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-2.1.0.tgz#ad3f5bf7856114f6fcab901b0502e2a2bc39d4eb" + dependencies: + postcss "^7.0.6" + postcss-selector-parser "^6.0.0" + +postcss-modules-values@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-3.0.0.tgz#5b5000d6ebae29b4255301b4a3a54574423e7f10" + dependencies: + icss-utils "^4.0.0" + postcss "^7.0.6" + +postcss-pxtorem@^4.0.1: + version "4.0.1" + resolved "https://registry.npmjs.org/postcss-pxtorem/-/postcss-pxtorem-4.0.1.tgz#9c64d0efe4885473cc1cb0305c6ffc3ebb45b1cd" + dependencies: + object-assign "^4.1.0" + postcss "^5.2.10" + +postcss-pxtransform@^1.3.2: + version "1.3.2" + resolved "https://registry.npmjs.org/postcss-pxtransform/-/postcss-pxtransform-1.3.2.tgz#73615a1a102938902363f4e18d4e860695f49fa5" + dependencies: + postcss "^6.0.16" + postcss-pxtorem "^4.0.1" + +postcss-selector-parser@^6.0.0, postcss-selector-parser@^6.0.2: + version "6.0.2" + resolved "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.2.tgz#934cf799d016c83411859e09dcecade01286ec5c" + dependencies: + cssesc "^3.0.0" + indexes-of "^1.0.1" + uniq "^1.0.1" + +postcss-value-parser@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.0.0.tgz#99a983d365f7b2ad8d0f9b8c3094926eab4b936d" + +postcss@^5.2.10: + version "5.2.18" + resolved "https://registry.npmjs.org/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5" + dependencies: + chalk "^1.1.3" + js-base64 "^2.1.9" + source-map "^0.5.6" + supports-color "^3.2.3" + +postcss@^6.0.16: + version "6.0.23" + resolved "https://registry.npmjs.org/postcss/-/postcss-6.0.23.tgz#61c82cc328ac60e677645f979054eb98bc0e3324" + dependencies: + chalk "^2.4.1" + source-map "^0.6.1" + supports-color "^5.4.0" + +postcss@^7.0.0, postcss@^7.0.14, postcss@^7.0.16, postcss@^7.0.17, postcss@^7.0.5, postcss@^7.0.6: + version "7.0.17" + resolved "https://registry.npmjs.org/postcss/-/postcss-7.0.17.tgz#4da1bdff5322d4a0acaab4d87f3e782436bad31f" + dependencies: + chalk "^2.4.2" + source-map "^0.6.1" + supports-color "^6.1.0" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" +prepend-http@^1.0.0: + version "1.0.4" + resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + prettier@^1.14.2: version "1.17.1" resolved "https://registry.npmjs.org/prettier/-/prettier-1.17.1.tgz#ed64b4e93e370cb8a25b9ef7fef3e4fd1c0995db" @@ -4406,6 +4734,13 @@ qs@~6.5.2: version "6.5.2" resolved "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" +query-string@^4.1.0: + version "4.3.4" + resolved "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb" + dependencies: + object-assign "^4.1.0" + strict-uri-encode "^1.0.0" + querystring-es3@^0.2.0: version "0.2.1" resolved "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" @@ -4757,7 +5092,7 @@ semver@~5.3.0: version "5.3.0" resolved "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" -serialize-javascript@^1.4.0: +serialize-javascript@^1.4.0, serialize-javascript@^1.7.0: version "1.7.0" resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.7.0.tgz#d6e0dfb2a3832a8c94468e6eb1db97e55a192a65" @@ -4874,6 +5209,12 @@ snapdragon@^0.8.1: source-map-resolve "^0.5.0" use "^3.1.0" +sort-keys@^1.0.0: + version "1.1.2" + resolved "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" + dependencies: + is-plain-obj "^1.0.0" + source-list-map@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" @@ -4911,7 +5252,7 @@ source-map@^0.4.2: dependencies: amdefine ">=0.0.4" -source-map@^0.5.0, source-map@^0.5.6, source-map@^0.5.7: +source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7: version "0.5.7" resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -5020,6 +5361,10 @@ stream-shift@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" +strict-uri-encode@^1.0.0: + version "1.1.0" + resolved "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" + string-length@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" @@ -5104,11 +5449,25 @@ strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" +stylus-loader@^3.0.2: + version "3.0.2" + resolved "https://registry.npmjs.org/stylus-loader/-/stylus-loader-3.0.2.tgz#27a706420b05a38e038e7cacb153578d450513c6" + dependencies: + loader-utils "^1.0.2" + lodash.clonedeep "^4.5.0" + when "~3.6.x" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^5.3.0: +supports-color@^3.2.3: + version "3.2.3" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + dependencies: + has-flag "^1.0.0" + +supports-color@^5.3.0, supports-color@^5.4.0: version "5.5.0" resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" dependencies: @@ -5349,6 +5708,27 @@ uglify-js@^3.1.4: commander "~2.20.0" source-map "~0.6.1" +uglify-js@^3.5.12: + version "3.6.0" + resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5" + dependencies: + commander "~2.20.0" + source-map "~0.6.1" + +uglifyjs-webpack-plugin@^2.1.3: + version "2.1.3" + resolved "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-2.1.3.tgz#b00a18d1acda271deb755c99ba0d93568156eb76" + dependencies: + cacache "^11.3.2" + find-cache-dir "^2.1.0" + is-wsl "^1.1.0" + schema-utils "^1.0.0" + serialize-javascript "^1.7.0" + source-map "^0.6.1" + uglify-js "^3.5.12" + webpack-sources "^1.3.0" + worker-farm "^1.7.0" + union-value@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" @@ -5358,6 +5738,10 @@ union-value@^1.0.0: is-extendable "^0.1.1" set-value "^0.4.3" +uniq@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" + unique-filename@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" @@ -5395,6 +5779,14 @@ urix@^0.1.0: version "0.1.0" resolved "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" +url-loader@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/url-loader/-/url-loader-2.0.0.tgz#600ef36f463e21bd673ad70156d850619d9cd092" + dependencies: + loader-utils "^1.1.0" + mime "^2.0.3" + schema-utils "^1.0.0" + url@^0.11.0: version "0.11.0" resolved "https://registry.npmjs.org/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" @@ -5501,7 +5893,14 @@ webpack-format-messages@^2.0.5: dependencies: kleur "^3.0.0" -webpack-sources@^1.1.0, webpack-sources@^1.3.0: +webpack-log@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/webpack-log/-/webpack-log-2.0.0.tgz#5b7928e0637593f119d32f6227c1e0ac31e1b47f" + dependencies: + ansi-colors "^3.0.0" + uuid "^3.3.2" + +webpack-sources@^1.0.1, webpack-sources@^1.1.0, webpack-sources@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz#2a28dcb9f1f45fe960d8f1493252b5ee6530fa85" dependencies: @@ -5563,6 +5962,10 @@ whatwg-url@^7.0.0: tr46 "^1.0.1" webidl-conversions "^4.0.2" +when@~3.6.x: + version "3.6.4" + resolved "https://registry.npmjs.org/when/-/when-3.6.4.tgz#473b517ec159e2b85005497a13983f095412e34e" + which-module@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" @@ -5591,7 +5994,7 @@ wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" -worker-farm@^1.5.2: +worker-farm@^1.5.2, worker-farm@^1.7.0: version "1.7.0" resolved "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz#26a94c5391bbca926152002f69b84a4bf772e5a8" dependencies: