Skip to content

Fix running tests. Update packages. Modify bundler #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ArtDanshin
Copy link
Member

  • Починил запуск тестов
  • Обновил пакеты до последних версий
  • Немного изменил логику сборки vendorов. Теперь в вендор попадают только те пакеты, которые находятся в папке node_modules и только тогда, когда они встречаются во входных точках
  • Немного улучшил работу source map'ов стилей в Development режиме. Теперь в инспекторе можно видеть расположение стиля непосредственно в stylus файле, а не в итоговом css

@@ -8,7 +8,7 @@
module.exports = function(_path) {
return {
context: _path,
devtool: 'eval',
devtool: 'inline-source-map',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для дев окружения лучше всего использовать eval-source-map. Он дает лучший маппинг артифактов на сорцы при максимальной скорости билдов.

При этом для прод сборок стоит использовать полноценный source-map.

]
}
},
'stylus-loader'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для правильной поддержки сорсмапов stylus-loader нужно тоже указать параметр sourceMap: true.

use: TextPlugin.extract([
{
loader: 'css-loader',
options: { sourceMap: true }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

css-loader должен применяться последним лоадером. За это отвечает параметр importLoaders. В данном конфиге у него должно быть значение 2.

В итоге конфиг должен выглядеть следующим образом:

[
  {
    loader: 'css-loader',
    options: {
      sourceMap: true,
      importLoaders: 2,
    },
  },
  {
    loader: 'postcss-loader',
    options: {
      sourceMap: true,
      context: rootAssetPath,
      plugins() {
        return [
          autoprefixer({
            remove: false,
            browsers: ['last 5 versions']
          }),
        ];
      },
    },
  },
  {
    loader: 'stylus-loader',
    options: {
      sourceMap: true,
    },
  },
]

loader: 'file-loader',
options: {
context: rootAssetPath,
name: path.join('assets','static', '[ext]', '[name].[hash].[ext]')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут какой-то перебор с path.join.

{
  name: path.join('assets','static', '[ext]', '[name].[hash].[ext]'),
}

Равнозначно

{
  name: 'assets/static/[ext]/[name].[hash].[ext]',
}

Только последний короче и воспринимается проще.

@@ -83,19 +99,16 @@ module.exports = function(_path) {
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
filename: 'assets/js/vendors.[hash].js'
filename: path.join('assets', 'js', '[name].[hash].js'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут тоже лучше обойтись без path.join

use: {
loader: 'babel-loader',
options: {
presets: ['es2015'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В резолвинге есть модули с расширением .jsx, но в лоадере нет react пресета? 🤔

presets: ['es2015'],
cacheDirectory: true,
use: {
loader: 'babel-loader',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Конфиг лоадера дублируется. Нужно его вынести в переменную

use: [
'style-loader',
'css-loader',
'stylus-loader']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что-то тестовый конфиг отличается от того что используется в дев и прод сборках. Это не правильно

name: 'vendors',
filename: '[name].js',
children: true,
minChunks: module => /node_modules/.test(module.resource) && !/.css/.test(module.resource)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дублирование конфига. Нужно вынести в общий модуль или не переопределять секцию plugins

"file-loader": "0.11.2",
"glob": "7.1.2",
"html-webpack-plugin": "2.30.1",
"json-loader": "0.5.7",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json-loader не нужен начиная с webpack@2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants