Skip to content

Commit

Permalink
feat: Npm run start now works. PostCSS needs some work
Browse files Browse the repository at this point in the history
  • Loading branch information
jmahc committed Jun 26, 2020
1 parent 027a8bc commit e98925b
Show file tree
Hide file tree
Showing 28 changed files with 98 additions and 500 deletions.
2 changes: 1 addition & 1 deletion config/_old/webpack.config.vendor.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import webpack from 'webpack'
* for instructions on resolving the errors by excluding the
* vendor dependency that is throwing an error.
*/
import entries from './dependencies.babel'
import entries from '../dependencies.babel'
import PATHS from './paths'

// NOTE: The library and the plugin's filename MUST match.
Expand Down
9 changes: 0 additions & 9 deletions config/alias.config.js

This file was deleted.

4 changes: 1 addition & 3 deletions config/dependencies.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
dependencies
} from '../package.json'
import { dependencies } from '../package.json'

/**
* Exclude any package.json dependencies that throw errors here.
Expand Down
10 changes: 3 additions & 7 deletions config/development.webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import path from 'path'
import webpack from 'webpack'

import {
devServerConfig,
alias,
devPerformanceOptions,
nodeOptions,
PATHS,
Expand Down Expand Up @@ -172,7 +172,7 @@ export default function developmentWebpack() {
safe: false,
}),
new HtmlWebpackPlugin({
// chunksSortMode: 'auto',
chunksSortMode: 'auto',
favicon: PATHS.favicon,
filename: 'index.html',
inject: true,
Expand All @@ -197,11 +197,7 @@ export default function developmentWebpack() {
}),
],
resolve: {
alias: {
'@': PATHS.appSrc,
'%': PATHS.sharedDir,
'react-dom': '@hot-loader/react-dom',
},
alias,
aliasFields: ['browser'],
descriptionFiles: ['package.json'],
enforceExtension: false,
Expand Down
4 changes: 1 addition & 3 deletions config/helpers/is-vendor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export const isVendor = ({
resource
}) =>
export const isVendor = ({ resource }) =>
resource && resource.indexOf('node_modules') >= 0 && resource.match(/.js$/)
25 changes: 0 additions & 25 deletions config/loaders.js

This file was deleted.

8 changes: 8 additions & 0 deletions config/options/alias.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PATHS } from './paths'

export const alias = {
'@': PATHS.appSrc,
'%': PATHS.sharedDir,
'#': PATHS.stylesDir,
'react-dom': '@hot-loader/react-dom',
}
8 changes: 2 additions & 6 deletions config/options/dev-server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
stats
} from './stats'
import {
PATHS
} from './paths'
import { stats } from './stats'
import { PATHS } from './paths'

export const devServerConfig = () => {
console.log('dev server config')
Expand Down
1 change: 1 addition & 0 deletions config/options/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './alias.config'
export * from './dev-server'
export * from './node-options'
export * from './paths'
Expand Down
7 changes: 3 additions & 4 deletions config/options/paths.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import fs from 'fs'
import path from 'path'

import {
dllPrefix
} from '../constants'
import { dllPrefix } from '../constants'

const currentDir = process.cwd()
const isProduction = process.env.NODE_ENV === 'production'
Expand All @@ -23,14 +21,15 @@ export const PATHS = {
favicon: resolvePath('public/favicon/favicon.ico'),
// Uncomment this for `favicons-webpack-plugin`
// image: resolvePath('src/shared/assets/images/spy_kid.png'),
indexHtml: resolvePath('public/index.html'),
indexHtml: resolvePath('public/index.ejs'),
nodeModules: resolvePath('node_modules'),
packageJson: resolvePath('package.json'),
polyfills: resolvePath('config/helpers/polyfills'),
postCssConfig: resolvePath('config/postcss.config.js'),
publicPath: isProduction ? './' : '/',
root: currentDir,
sharedDir: resolvePath('src/shared'),
stylesDir: resolvePath('src/shared/styles'),
vendors: {
filepath: resolvePath(`node_modules/${dllPrefix}/vendors.dll.js`),
manifest: resolvePath(`node_modules/${dllPrefix}/vendors-manifest.json`),
Expand Down
2 changes: 1 addition & 1 deletion config/options/performance-options.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const devPerformanceOptions = {
hints: false
hints: false,
}
2 changes: 1 addition & 1 deletion config/options/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export const stats = {
modules: false,
publicPath: true,
reasons: true,
warnings: true
warnings: true,
}
33 changes: 31 additions & 2 deletions config/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
// const postcssPresetEnv = require('postcss-preset-env');

module.exports = {
// This parser (may or may not) remove inline comments (not allowed in .css): // My Comment
// parser: 'postcss-scss',
// plugins: [require('precss'), require('autoprefixer')],
plugins: [],
// plugins: {
// 'postcss-import': {
// path: ['src/shared/styles'],
// },
// 'postcss-color-function': {},
// 'postcss-cssnext': {
// browsers: 'last 2 versions',
// warnForDuplicates: false,
// },
// cssnano: {},
// },
plugins: [
//
require('precss'),
require('autoprefixer'),
require('postcss-color-function'),
require('postcss-import'),
require('postcss-strip-inline-comments'),
require('postcss-preset-env')({
autoprefixer: { grid: true },
browsers: 'last 2 versions',
// importFrom: 'path/to/file.css',
/* use stage 3 features + css color-mod (warning on unresolved) */
stage: 3,
features: {
'color-mod-function': { unresolved: 'warn' },
},
}),
],
}
14 changes: 5 additions & 9 deletions config/vendors.webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import webpack from 'webpack'
* for instructions on resolving the errors by excluding the
* vendor dependency that is throwing an error.
*/
import {
vendorEntries
} from './dependencies.babel'
import {
dllPrefix
} from './constants'
import { vendorEntries } from './dependencies.babel'
import { dllPrefix } from './constants'

export default function vendorsWebpack() {
const basePath = process.cwd()
Expand All @@ -23,7 +19,7 @@ export default function vendorsWebpack() {
target: 'web',
mode: 'development',
entry: {
vendors: vendorEntries
vendors: vendorEntries,
},
output: {
path: path.join(basePath, 'node_modules', dllPrefix),
Expand All @@ -44,10 +40,10 @@ export default function vendorsWebpack() {
}),
],
optimization: {
minimize: false
minimize: false,
},
performance: {
hints: false
hints: false,
},
}
}
Loading

0 comments on commit e98925b

Please sign in to comment.