• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript extract-text-webpack-plugin.extract函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中extract-text-webpack-plugin.extract函数的典型用法代码示例。如果您正苦于以下问题:TypeScript extract函数的具体用法?TypeScript extract怎么用?TypeScript extract使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了extract函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1:

 cssLoaders.push(...baseRules.map(({test, loaders}) => ({
   include: stylePaths, test, loaders: ExtractTextPlugin.extract({
     remove: false,
     loader: ['css-loader', ...commonLoaders, ...loaders],
     fallbackLoader: 'style-loader'
   })
 })));
开发者ID:marc-sensenich,项目名称:angular-cli,代码行数:7,代码来源:webpack-build-utils.ts


示例2:

    rules.push(...baseRules.map(({test, use}) => {
      const extractTextPlugin = {
        use: [
          ...commonLoaders,
          {
            loader: 'postcss-loader',
            options: {
              ident: buildOptions.extractCss ? 'extracted' : 'embedded',
              plugins: postcssPluginCreator,
              sourceMap: cssSourceMap
            }
          },
          ...(use as webpack.Loader[])
        ],
        // publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
        publicPath: ''
      };
      const ret: any = {
        include: globalStylePaths,
        test,
        use: buildOptions.extractCss ? ExtractTextPlugin.extract(extractTextPlugin)
                                     : ['style-loader', ...extractTextPlugin.use]
      };
      // Save the original options as arguments for eject.
      if (buildOptions.extractCss) {
        ret[pluginArgs] = extractTextPlugin;
      }
      return ret;
    }));
开发者ID:deebloo,项目名称:angular-cli,代码行数:29,代码来源:styles.ts


示例3:

 rules.push(...baseRules.map(({test, loaders}) => ({
   include: globalStylePaths, test, loaders: ExtractTextPlugin.extract({
     remove: false,
     loader: ['css-loader', ...commonLoaders, ...loaders],
     fallbackLoader: 'style-loader',
     // publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
     publicPath: ''
   })
 })));
开发者ID:jeremymwells,项目名称:angular-cli,代码行数:9,代码来源:styles.ts


示例4:

 rules.push(...baseRules.map(({test, loaders}) => ({
   include: globalStylePaths, test, loaders: ExtractTextPlugin.extract({
     use: [
       // css-loader doesn't support webpack.LoaderOptionsPlugin properly,
       // so we need to add options in its query
       `css-loader?${JSON.stringify({ sourceMap: cssSourceMap })}`,
       ...commonLoaders,
       ...loaders
     ],
     fallback: 'style-loader',
     // publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
     publicPath: ''
   })
 })));
开发者ID:Percyman,项目名称:angular-cli,代码行数:14,代码来源:styles.ts


示例5: getCSSConfig

export function getCSSConfig() {
  const projectRoot: string = process.env.PWD;
  const styles = config.getJSON().apps.map(app => app.styles);
  let entries = {};

  styles.forEach(style => {
    for (let src in style) {
      if (helper.existsSync(path.resolve(projectRoot, src))) {
        entries[style[src].output] = path.resolve(projectRoot, `./${src}`);
      }
    }
  });

  return {
    name: 'styles',
    context: process.env.CLI_ROOT,
    resolve: {
      root: path.resolve(projectRoot)
    },
    entry: entries,
    output: {
      path: path.join(projectRoot, './build'),
      filename: '[name]'
    },
    module: {
      loaders: [
        { test: /\.css$/i, loader: ExtractTextPlugin.extract(['css-loader']) },
        { test: /\.sass$|\.scss$/i, loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) },
        { test: /\.less$/i, loader: ExtractTextPlugin.extract(['css-loader', 'less-loader']) },
        { test: /\.styl$/i, loader: ExtractTextPlugin.extract(['css-loader', 'stylus-loader']) }
      ]
    },
    plugins: [
      new ExtractTextPlugin('[name]')
    ]
  }
};
开发者ID:jkuri,项目名称:ng2-cli,代码行数:37,代码来源:webpack.config.css.ts


示例6:

 rules.push(...baseRules.map(({test, loaders}) => {
   const extractTextPlugin = {
     use: [
       ...commonLoaders,
       ...loaders
     ],
     fallback: 'style-loader',
     // publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
     publicPath: ''
   };
   const ret: any = {
     include: globalStylePaths, test, loaders: ExtractTextPlugin.extract(extractTextPlugin)
   };
   // Save the original options as arguments for eject.
   ret[pluginArgs] = extractTextPlugin;
   return ret;
 }));
开发者ID:itslenny,项目名称:angular-cli,代码行数:17,代码来源:styles.ts


示例7: Loader

export default function StyleLoader
	( name:string
	, extensions:string[]
	, specificStyleLoader:string|any[]
	, o:WPACK.Loader
	)
	{ 

		const isDev = !o.isProd;

		const loadersArray = 
			[  isDev && 'style-loader'
			, ...stylesLoaders
			, specificStyleLoader
			].filter(Boolean);

		const loaders = o.isServer ? 
			'ignore-loader' :
			isDev ? 
				loadersArray : 
				ExtractTextPlugin.extract('style-loader',combineLoaders(loadersArray)) 

		return Loader(name,'style',extensions,loaders,o);
	}
开发者ID:Xananax,项目名称:wpack,代码行数:24,代码来源:StyleLoader.ts


示例8: StyleLintPlugin

     enforce: 'pre',
     test: /\.ts$/,
     loader: 'tslint-loader?emitErrors=true&failOnHint=true',
     exclude: /node_modules/
   }, {
     enforce: 'pre',
     test: /ng\-bootstrap\/util\/positioning/,
     loader: 'source-map-loader'
   }, {
     test: /\.ts$/,
     loader: 'awesome-typescript-loader?module=es2015',
     exclude: /node_modules/
   }, {
     test: /\.scss/,
     loader: ExtractTextPlugin.extract({
       fallbackLoader: 'style-loader',
       loader: 'css-loader!postcss-loader!sass-loader'
     }),
     exclude: /node_modules/
   }]
 },
 resolve: {
   extensions: ['.ts', '.js']
 },
 plugins: [
   new StyleLintPlugin({
     syntax: 'scss',
     context: 'scss',
     failOnError: true
   }),
   new ExtractTextPlugin('./../css/angular-calendar.css'),
   new webpack.SourceMapDevToolPlugin({
开发者ID:thomasjosephgreco,项目名称:angular2-calendar,代码行数:32,代码来源:webpack.config.umd.ts


示例9: ExtractTextPlugin

module.exports = (env: env = {}) => {
  console.log({ env });
  const isBuild = !!env.build;
  const isDev = !env.build;
  const isSourceMap = !!env.sourceMap || isDev;

  return {
    cache: true,
    devtool: isDev ? 'eval-source-map' : 'source-map',
    devServer: DEV_SERVER,

    context: PATHS.root,

    entry: {
      app: [
        // 'react-hot-loader/patch',
        './src/index.tsx',
      ],
    },
    output: {
      path: PATHS.build,
      filename: isDev ? '[name].js' : '[name].[hash].js',
      publicPath: '/',
    },

    resolve: {
      extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
      modules: ['src', 'node_modules'],
    },
    
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          include: PATHS.src,
          loader: (env.awesome ?
              [
                {
                  loader: 'awesome-typescript-loader',
                  options: {
                    transpileOnly: true,
                    useTranspileModule: false,
                    sourceMap: isSourceMap,
                  },
                },
              ] : [
                {
                  loader: 'ts-loader',
                  options: {
                    transpileOnly: true,
                    compilerOptions: {
                      'sourceMap': isSourceMap,
                      'target': isDev ? 'es2015' : 'es5',
                      'isolatedModules': true,
                      'noEmitOnError': false,
                    },
                  },
                },
              ]
          ),
        },
        {
          test: /\.js$/,
          exclude: /(node_modules|bower_components)/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['env']
            }
          }
        },
        {
          test: /\.json$/,
          include: [PATHS.src],
          loader: { loader: 'json-loader' },
        },
        {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract({
            use: 'css-loader'
          })
        },
        {
          test: /\.scss$/,
          loader: ExtractTextPlugin.extract({
            fallback: "style-loader",
            use: "css-loader!sass-loader",
          }),
        },
        {
          test: /\.(jpe?g|png|gif|svg|ico)$/i,
          loaders: [
            'file-loader?hash=sha512&limit=1000&digest=hex&name=[hash].[ext]',
            'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false'
          ]
        }
      ],
    },
    plugins: [
      StyleLintPlugin(),
//.........这里部分代码省略.........
开发者ID:langkilde,项目名称:fatbat,代码行数:101,代码来源:webpack.config.ts


示例10: default

export default (env: { production?: boolean } = {}) => {
  const babelPlugins = env.production ? ['emotion', 'lodash'] : ['emotion']

  const babelLoader: webpack.Loader = {
    loader: 'babel-loader',
    options: {
      plugins: babelPlugins,
    },
  }

  const tsLoader: webpack.Loader = {
    loader: 'ts-loader',
    options: {
      compilerOptions: {
        module: 'esnext',
      },
      transpileOnly: true,
    },
  }

  const cssLoader: webpack.Loader = {
    loader: 'css-loader',
    options: {
      minimize: env.production,
    },
  }

  const sourceRule: webpack.Rule = {
    test: /\.tsx?$/,
    use: [babelLoader, tsLoader],
    include: [sourcePath],
  }

  const cssLoaderRule: webpack.Rule = {
    test: /\.css$/,
    use: ExtractTextPlugin.extract({
      use: [cssLoader],
      fallback: 'style-loader',
    }),
  }

  const baseConfig: webpack.Configuration = {
    entry: {
      app: resolve(sourcePath, 'main'),
    },
    output: {
      filename: 'js/[name].js',
      path: outputPath,
    },
    module: {
      rules: [sourceRule, cssLoaderRule],
    },
    plugins: [
      new HTMLPlugin({
        template: './index.html',
        chunksSortMode: 'dependency',
        inject: 'head',
      }),

      new ScriptExtHtmlPlugin({
        defaultAttribute: 'defer',
      }),

      new ExtractTextPlugin({
        filename: 'css/[name].css',
        disable: !env.production,
      }),

      new webpack.DefinePlugin({
        APP_NAME: JSON.stringify(meta.name),
        APP_VERSION: JSON.stringify(meta.version),
      }),

      new ForkTsCheckerWebpackPlugin({
        tslint: true,
      }),
    ],
    resolve: {
      extensions: ['.js', '.json', '.ts', '.tsx'],
    },
    devServer: {
      historyApiFallback: true,
    },
  }

  const devConfig: webpack.Configuration = {
    plugins: [new webpack.NamedModulesPlugin()],
    devtool: 'eval-source-map',
  }

  const prodConfig: webpack.Configuration = {
    plugins: [
      new CleanPlugin(['build'], { verbose: false }),

      new webpack.DefinePlugin({
        'process.env.NODE_ENV': '"production"',
      }),

      new webpack.optimize.CommonsChunkPlugin({
        name: 'lib',
//.........这里部分代码省略.........
开发者ID:Kingdaro,项目名称:fchat,代码行数:101,代码来源:webpack.config.ts



注:本文中的extract-text-webpack-plugin.extract函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript extraterm-extension-api.TextViewer类代码示例发布时间:2022-05-25
下一篇:
TypeScript util.Log类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap