Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(env, 'Init CSS Modules in Production mode...')
webpack.loader('css', {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', [cssModules, 'postcss']),
})
webpack.merge({
plugins: [new ExtractTextPlugin('styles.css', {ignoreOrder: true})],
})
}
// favicons-webpack-plugin
if (env === 'build-html') {
console.log(env, 'Auto-generating Icons...')
webpack.merge({
plugins: [
new FaviconsPlugin({
background: '#fff', // @TODO dark bg color .org
emitStats: false,
inject: false,
logo: 'static/assets/img/mark.png',
persistentCache: true,
prefix: '/',
title: config.siteHost,
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: true,
favicons: true,
firefox: true,
windows: true,
yandex: true,
})
webpack.loader('jpg', {
test: /\.(jpg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: ['file-loader'],
})
webpack.loader('png', {
test: /\.(png)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loaders: ['file-loader'],
})
// favicons-webpack-plugin
if (env === 'build-html') {
console.log(env, 'Auto-generating Icons...')
webpack.merge({
plugins: [
new FaviconsPlugin({
background: '#fff', // @TODO dark bg color .org
emitStats: false,
inject: false,
logo: 'components/LogoMark/images/mark.png',
persistentCache: true,
prefix: '/',
title: config.siteHost,
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: true,
favicons: true,
firefox: true,
windows: true,
yandex: true,
console.log(env, 'Init CSS Modules in Production mode...')
webpack.loader('css', {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', [cssModules, 'postcss']),
})
webpack.merge({
plugins: [new ExtractTextPlugin('styles.css', {ignoreOrder: true})],
})
}
// favicons-webpack-plugin
if (env === 'build-html') {
console.log(env, 'Auto-generating Icons...')
webpack.merge({
plugins: [
new FaviconsPlugin({
background: '#fff',
emitStats: false,
inject: false,
logo: 'static/assets/img/mark.png',
persistentCache: true,
prefix: '/',
title: config.siteHost,
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: true,
favicons: true,
firefox: true,
windows: true,
yandex: true,
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2|mp3)$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'assets/[name]_[hash].[ext]',
},
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'style_[hash].css',
chunkFilename: '[id].css',
}),
new FaviconsWebpackPlugin('favicon.png'),
new HtmlWebpackPlugin({
template: './index.ejs',
title: 'Quick VR Demo',
minify: {
removeComments: true,
collapseWhitespace: true,
},
inject: true,
}),
new RobotstxtPlugin(),
],
devServer: {
contentBase: path.join(__dirname, 'dist'),
},
};
import webpack from 'webpack';
import FaviconsWebpackPlugin from 'favicons-webpack-plugin';
import { envMap, envSetup } from './defaults/environments';
import { buildFavicon } from './defaults/build-favicon';
import { baseEnvironment } from './base.environment';
const devEnvironment = {
...baseEnvironment,
devtool: 'cheap-module-source-map',
plugins: [
...(baseEnvironment.plugins || []),
new FaviconsWebpackPlugin(buildFavicon(true)),
new webpack.DefinePlugin(envSetup(envMap.dev)),
],
};
export default devEnvironment;
import { envMap, envSetup } from './defaults/environments';
import { buildRules } from './defaults/build-rules';
import { buildPage } from './defaults/build-page';
import { buildFavicon } from './defaults/build-favicon';
import { baseEnvironment } from './base.environment';
const prodEnvironment = {
...baseEnvironment,
devtool: false,
module: {
rules: buildRules(true),
},
plugins: [
...(baseEnvironment.plugins || []),
new HtmlWebpackPlugin(buildPage(true)),
new FaviconsWebpackPlugin(buildFavicon(true)),
new webpack.DefinePlugin(envSetup(envMap.prod)),
new webpack.optimize.UglifyJsPlugin({ comments: false }),
new CompressionPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
],
};
export default prodEnvironment;
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [`${paths.distAbsolute}/*`].concat((app.cleanExclusions || [])
.map((exclusion) => `!${paths.distAbsolute}/${exclusion}`)),
}),
new CopyWebpackPlugin(app.externalFiles.map((filesRules) => {
const parsedRules = typeof filesRules === 'string' ? { from: filesRules } : filesRules;
return {
...parsedRules,
to: `${paths.distAbsolute}/${parsedRules.to || ''}`,
ignore: parsedRules.ignore || ['.*'],
};
})),
...(app.style.extract ? [new MiniCssExtractPlugin({ filename: app.output.style })] : []),
new HtmlWebpackPlugin(page.pretty),
new FaviconsWebpackPlugin(favicon.minimum),
new ManifestJsonWebpackPlugin(manifest.pretty),
],
resolve: {
extensions: Object.values(app.extensions).reduce(reduceFlatten, []).map((ext) => `.${ext}`),
modules: [
paths.appAbsolute,
'node_modules',
],
},
};
import { getVariables } from './runtime';
import { app, favicon, paths } from './settings';
import { environments } from './environments';
import { baseConfig } from './base.config';
const { style, compileExclusions } = app;
const environmentVariables = getVariables(environments.dev);
export const config = {
...baseConfig,
module: {
rules: rules.getPretty(style.global, style.extract, compileExclusions, environmentVariables),
},
plugins: [
...(baseConfig.plugins || []),
new FaviconsWebpackPlugin(favicon.all),
new ExtendedDefinePlugin(environmentVariables),
new PrerenderSpaPlugin(app.rendering),
...(app.style.extract ? [new CriticalCssPlugin({ base: paths.distAbsolute })] : []),
],
};
export const config = {
...baseConfig,
devtool: false,
mode: 'production',
module: {
rules: rules.getMinified(style.global, style.extract, compileExclusions, environmentVariables),
},
optimization: {
...baseConfig.optimization,
minimize: true,
},
plugins: [
...(baseConfig.plugins || []),
new HtmlWebpackPlugin(page.minified),
new FaviconsWebpackPlugin(favicon.all),
new ManifestJsonWebpackPlugin(manifest.minified),
new ExtendedDefinePlugin(environmentVariables),
new PrerenderSpaPlugin(app.rendering),
...(app.style.extract ? [new CriticalCssPlugin({ base: paths.distAbsolute })] : []),
new NoEmitOnErrorsPlugin(),
],
};
ifDevelopment(new ProgressBarPlugin()),
new webpack.NoErrorsPlugin(),
extractCSS,
new HtmlWebpackPlugin({ template: './index.html' }),
new ExtendedDefinePlugin({ APP_CONFIG: getAppConfig(env) }),
new webpack.LoaderOptionsPlugin({
minimize: ifNotDevelopment(true),
options: {
eslint: {
formatter: require('eslint-friendly-formatter'),
configFile: '.eslintrc',
quiet: true
}
}
}),
new FaviconsWebpackPlugin('./assets/img/syncano-symbol.svg'),
ifNotDevelopment(...[
new InlineManifestWebpackPlugin(),
new WebpackMd5Hash(),
new webpack.optimize.CommonsChunkPlugin({
async: true,
children: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
filename: 'manifest.js',
minChunks: Infinity,
}),
new ContextReplacementPlugin(/brace[\\\/]mode$/, /^\.\/(javascript|html|python|ruby|golang|swift|php|django|json|css|text)$/),
new ContextReplacementPlugin(/brace[\\\/]theme$/, /^\.\/(tomorrow)$/),
new ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(en-uk|en-us|en-au)$/),
new CompressionPlugin({