Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
CSS compilation rules moved to common config due to cover ssr scenerios.
Browse files Browse the repository at this point in the history
  • Loading branch information
eser committed Nov 4, 2018
1 parent 63a8a4c commit 9efc617
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 137 deletions.
66 changes: 0 additions & 66 deletions core/etc/webpack.browser.js
Expand Up @@ -3,7 +3,6 @@ const { configWrapper, commonConfig } = require('./webpack.common');

const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractCssChunksPlugin = require('extract-css-chunks-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const browserConfig = configWrapper((vars) => {
Expand Down Expand Up @@ -76,64 +75,6 @@ const browserConfig = configWrapper((vars) => {

rules: [
...common.module.rules,

{
test: /\.s[ac]ss$/,
use: [
ExtractCssChunksPlugin.loader,
{
loader: 'typings-for-css-modules-loader',
options: {
importLoaders: 2,
sourceMap: true,
modules: true,
namedExport: true,
camelCase: true,
// localIdentName: '[local]___[hash:base64:5]',
localIdentName: '[local]',
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
path: __dirname,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.css$/,
use: [
ExtractCssChunksPlugin.loader,
{
loader: 'typings-for-css-modules-loader',
options: {
importLoaders: 2,
sourceMap: true,
modules: true,
namedExport: true,
camelCase: true,
// localIdentName: '[local]___[hash:base64:5]',
localIdentName: '[local]',
},
},
{
loader: 'postcss-loader',
options: {
parser: 'postcss-js',
sourceMap: true,
path: __dirname,
},
},
],
},
{
test: /\.(eot|ttf|jpe?g|png|gif|ico)([\?]?.*)$/,
use: [
Expand Down Expand Up @@ -177,13 +118,6 @@ const browserConfig = configWrapper((vars) => {

plugins: [
...common.plugins,
new ExtractCssChunksPlugin({
filename: '[name].css',
// chunkFilename: '[id].[chunkhash].css',
chunkFilename: '[id].css',
hot: true,
cssModules: true,
}),
new CopyWebpackPlugin(
vars.manifest.staticFiles.map(x => ({ from: x, to: './', flatten: true })),
),
Expand Down
72 changes: 68 additions & 4 deletions core/etc/webpack.common.js
@@ -1,6 +1,7 @@
/* eslint-env node */
const path = require('path');
const webpack = require('webpack');
const ExtractCssChunksPlugin = require('extract-css-chunks-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const DotenvPlugin = require('dotenv-webpack');
Expand Down Expand Up @@ -47,7 +48,6 @@ const commonConfig = (name) => configWrapper((vars) => {
},
{
test: /\.([tj]sx?|mjs)$/,
enforce: 'pre',
use: [
{
loader: 'ts-loader',
Expand All @@ -59,6 +59,63 @@ const commonConfig = (name) => configWrapper((vars) => {
],
// exclude: /node_modules/,
},
{
test: /\.s[ac]ss$/,
use: [
ExtractCssChunksPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
// localIdentName: '[local]___[hash:base64:5]',
localIdentName: '[local]',
sourceMap: true,
camelCase: true,
importLoaders: 2,
},
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
sourceMap: true,
path: __dirname,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.css$/,
use: [
ExtractCssChunksPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
// localIdentName: '[local]___[hash:base64:5]',
localIdentName: '[local]',
sourceMap: true,
camelCase: true,
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
parser: 'postcss-js',
sourceMap: true,
path: __dirname,
},
},
],
},
],
},

Expand Down Expand Up @@ -87,10 +144,17 @@ const commonConfig = (name) => configWrapper((vars) => {
DARTY_VARS: JSON.stringify(vars),
},
}),
new webpack.WatchIgnorePlugin([
/css\.d\.ts$/
]),
// new webpack.WatchIgnorePlugin([
// /css\.d\.ts$/
// ]),
new CaseSensitivePathsPlugin(),
new ExtractCssChunksPlugin({
filename: '[name].css',
// chunkFilename: '[id].[chunkhash].css',
chunkFilename: '[id].css',
hot: true,
cssModules: true,
}),
new DotenvPlugin({
// safe: `${vars.dartyRoot}/templates/.env.default`,
// path: './.env',
Expand Down
19 changes: 3 additions & 16 deletions core/etc/webpack.server.js
Expand Up @@ -41,22 +41,6 @@ const serverConfig = configWrapper((vars) => {

rules: [
...common.module.rules,
{
test: /\.s[ac]ss$/,
use: [
{
loader: 'css-loader/locals',
},
],
},
{
test: /\.css$/,
use: [
{
loader: 'css-loader/locals',
},
],
},
{
test: /\.(eot|ttf|jpe?g|png|gif|ico)([\?]?.*)$/,
use: [
Expand Down Expand Up @@ -101,6 +85,9 @@ const serverConfig = configWrapper((vars) => {
plugins: [
...common.plugins,
new webpack.NamedModulesPlugin(),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
};
});
Expand Down
47 changes: 7 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions package.json
Expand Up @@ -8,7 +8,7 @@
"boilerplate",
"starter"
],
"version": "0.50.1",
"version": "0.50.2",
"homepage": "https://github.com/eserozvataf/darty",
"author": "Eser Ozvataf <eser@ozvataf.com>",
"contributors": [
Expand Down Expand Up @@ -42,9 +42,9 @@
"autoprefixer": "^9.3.1",
"case-sensitive-paths-webpack-plugin": "^2.1.2",
"colors": "^1.3.2",
"copy-webpack-plugin": "^4.5.4",
"copy-webpack-plugin": "^4.6.0",
"cross-spawn": "^6.0.5",
"css-loader": "^1.0.0",
"css-loader": "^1.0.1",
"cssnano": "^4.1.7",
"dotenv-webpack": "^1.5.7",
"es6-promise": "^4.2.5",
Expand All @@ -57,22 +57,21 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^23.6.0",
"node-fetch": "^2.2.0",
"node-sass": "^4.9.4",
"node-sass": "^4.10.0",
"postcss": "^7.0.5",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-modules": "^1.4.1",
"postcss-nesting": "^7.0.0",
"sass-loader": "^7.1.0",
"ts-jest": "^23.10.4",
"ts-loader": "^5.2.2",
"ts-loader": "^5.3.0",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"tslib": "^1.9.3",
"typescript": "^3.1.3",
"typescript-eslint-parser": "^20.0.0",
"typings-for-css-modules-loader": "^1.7.0",
"typescript": "^3.1.6",
"typescript-eslint-parser": "^20.1.1",
"url-loader": "^1.1.2",
"webpack": "^4.23.1",
"webpack": "^4.24.0",
"webpack-async-chunk-names-plugin": "^0.1.1",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.1.2",
Expand All @@ -82,8 +81,8 @@
},
"devDependencies": {
"@types/express": "^4.16.0",
"@types/jest": "^23.3.8",
"@types/node": "^10.12.0",
"@types/jest": "^23.3.9",
"@types/node": "^10.12.2",
"@types/webpack": "^4.4.17"
}
}

0 comments on commit 9efc617

Please sign in to comment.