2.1.4 • Published 9 months ago

@flatjs/forge-plugin-styling v2.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

The flatjs plugin @flatjs/forge-plugin-styling

A plugin for compile less, sass, css for forge compiler. Note: the sass maybe will broken in macos node environment. we need to using node-sass.

Features

  • A plugin for compile less, sass, css for @flatjs/forge.
  • Use this plugin is suite for compile wechat miniprogram modular is better.
  • If we need to modular build react UI components(with stylings) recommend use rollup-plugin-postcss enable CSS modules for .module.css .module.sss .module.scss .module.sass .module.styl .module.stylus .module.less files.

Installation

$ npm i --save @flatjs/forge-plugin-styling

Configuration

export const testCompile = async (
  input: string | string[],
  options: forgePluginStylingOptions,
  distFolder?: string,
): Promise<boolean> => {
  // Note: `forgePluginStyling` is plugin of @flatjs/forge,
  // in most case we will use `ForgeBuildOptions` as build options.
  const stylingPlugin = forgePluginStyling(options);
  return startBuild(options.projectCwd, options.projectCwd, {
    input,
    output: {
      distFolder: distFolder || options.format,
      format: options.format,
      cleanDistFolder: false,
      // `@flatjs/forge` for javascript only.
      sourcemap: options.sourceMap,
      // we must set sourcemap: true, while sourcemapPathTransform
      sourcemapPathTransform(_relativeSourcePath: string, sourcemapPath: string) {
        return sourcemapPath;
      },
    },
    plugin: {
      extraPlugins: [stylingPlugin],
    },
  });
};

Usage

simple

const result = await testCompile('src/index.ts', {
  projectCwd,
  use: ['less', 'sass'],
  format: 'cjs',
  styleOutputExt: '.css',
});

See more

css

const result = await testCompile(['src/multi-entry-two.ts', 'src/multi-entry-one.ts'], {
  projectCwd,
  format: 'cjs',
});

See more

less

const result = await testCompile('src/index.ts', {
  projectCwd,
  use: ['less'],
  format: 'cjs',
});

See more

sass

const result = await testCompile('src/index.ts', {
  projectCwd,
  use: ['sass'],
  format: 'cjs',
  styleOutputExt: '.css',
});

See more

sourcemap

sourcemap.test.ts sourceMap:inline

// will generate inline sourcemap `css`.
const result = await testCompile('src/css/sourcemap.ts', {
  projectCwd,
  format: 'umd',
  sourceMap: 'inline',
});
// will generate inline sourcemap `less`.
const result1 = await testCompile('src/less/sourcemap.ts', {
  projectCwd,
  format: 'umd',
  sourceMap: 'inline',
});
// will generate inline sourcemap `sass`.
const result2 = await testCompile('src/sass/sourcemap.ts', {
  projectCwd,
  format: 'umd',
  sourceMap: 'inline',
});

sourcemap.test.ts sourceMap:true

// should generate sourcemap file `css`
const result = await testCompile('src/css/sourcemap-with-file.ts', {
  projectCwd,
  format: 'umd',
  sourceMap: true,
});

// should generate sourcemap file `less`
const lessOpt: Less.Options = {
  sourceMap: {
    sourceMapFileInline: true,
  },
};
const result = await testCompile('src/less/sourcemap-with-file.ts', {
  projectCwd,
  format: 'umd',
  // Note the final output sourceMap file.
  sourceMap: true,
  use: [['less', lessOpt]],
});

// should generate sourcemap file `sass`
const sassOpts: Options = {
  sourceMap: true,
};
const result = await testCompile('src/sass/sourcemap-with-file.ts', {
  projectCwd,
  format: 'umd',
  // Note the final output sourceMap file.
  sourceMap: true,
  use: [['sass', sassOpts]],
});

See more

wxss

const result = await testCompile(
  ['src/page1/index.ts', 'src/page2/index.ts'],
  {
    projectCwd,
    use: ['less'],
    format: 'cjs',
    autoAppendToModule: false,
    styleOutputExt: '.wxss',
  },
  'miniprogram',
);

See more

References

for sass processor

  • npm i node-sass
  • npm rebuild node-sass (if required(node-sass) failed)
2.1.4

9 months ago

2.1.3

10 months ago

2.1.2

10 months ago

2.1.0-next.4

1 year ago

2.1.0-next.9

12 months ago

2.1.0-next.6

1 year ago

2.1.0-next.5

1 year ago

2.1.0-next.8

1 year ago

2.1.0-next.7

1 year ago

2.1.1

11 months ago

2.1.0

11 months ago

2.1.0-next.3

1 year ago

2.1.0-next.2

1 year ago

2.1.0-next.1

1 year ago

2.1.0-next.0

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.8.1-next.34

2 years ago

1.8.1-next.33

2 years ago

1.8.1-next.36

2 years ago

1.8.1-next.35

2 years ago

1.8.1-next.38

2 years ago

1.8.1-next.37

2 years ago

1.8.1-next.39

2 years ago

1.8.1-next.41

2 years ago

1.8.1-next.40

2 years ago

1.8.1-next.43

2 years ago

1.8.1-next.42

2 years ago

1.8.1-next.44

2 years ago

2.0.0-next.2

2 years ago

2.0.0-next.3

2 years ago

2.0.0-next.1

2 years ago

1.8.1-next.29

2 years ago

1.8.1-next.28

2 years ago

1.8.1-next.30

2 years ago

1.8.1-next.32

2 years ago

1.8.1-next.31

2 years ago

1.7.1-next.0

2 years ago

1.7.1-next.2

2 years ago

1.7.1-next.1

2 years ago

1.8.1-next.21

2 years ago

1.8.1-next.20

2 years ago

1.8.1-next.23

2 years ago

1.7.1-next.4

2 years ago

1.6.0

2 years ago

1.8.1-next.22

2 years ago

1.7.1-next.3

2 years ago

1.8.1-next.25

2 years ago

1.8.1-next.24

2 years ago

1.7.1-next.5

2 years ago

1.8.1-next.27

2 years ago

1.8.1-next.7

2 years ago

1.8.1-next.26

2 years ago

1.8.1-next.6

2 years ago

1.8.1-next.9

2 years ago

1.8.1-next.8

2 years ago

1.7.2

2 years ago

1.7.0

2 years ago

1.8.1-next.10

2 years ago

1.8.1-next.12

2 years ago

1.8.1-next.11

2 years ago

1.8.1-next.14

2 years ago

1.8.1-next.16

2 years ago

1.8.1-next.15

2 years ago

1.8.1-next.18

2 years ago

1.8.1-next.17

2 years ago

1.8.1-next.19

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.17

3 years ago

1.3.13

3 years ago

1.3.14

3 years ago

1.3.12

3 years ago

1.3.11

3 years ago

1.3.6

3 years ago

1.3.9

3 years ago

1.3.5

3 years ago

1.3.3

3 years ago

1.3.0

3 years ago

1.2.101

3 years ago

1.2.100

3 years ago

1.2.98

4 years ago

1.2.99

4 years ago

1.2.96

4 years ago

1.2.97

4 years ago

1.2.95

4 years ago

1.2.94

4 years ago

1.2.93

4 years ago

1.2.90

4 years ago

1.2.83

4 years ago

1.2.82

4 years ago

1.2.81

4 years ago

1.2.80

4 years ago

1.2.79

4 years ago

1.2.78

4 years ago

1.2.77

4 years ago

1.2.76

4 years ago

1.2.75

4 years ago

1.2.74

4 years ago

1.2.73

4 years ago

1.2.70

4 years ago

1.2.69

4 years ago

1.2.68

4 years ago

1.2.67

4 years ago

1.2.66

4 years ago

1.2.65

4 years ago