diff --git a/.babelrc b/.babelrc index 3ed94dff9..c13c5f627 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,3 @@ { - "presets": [ - ["env", { "modules": false }] - ] + "presets": ["es2015"] } diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..d0dd64cbb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,4 @@ +{ + "root": true, + "extends": "vue" +} diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b31f02096..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - root: true, - extends: ['plugin:vue-libs/recommended'], - rules: { - indent: 'off', - 'space-before-function-paren': 'off' - } -} diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 6313b56c5..000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index bd0e4f286..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 0a3ad19f4..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: 'ci' -on: - push: - branches: - - master - pull_request: - branches: - - master -jobs: - unit-test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest - fail-fast: false - name: "Unit Test: ${{ matrix.os }}" - steps: - - uses: actions/checkout@v2 - - - name: Install pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - - - name: Set node version to 16 - uses: actions/setup-node@v2 - with: - node-version: 16 - cache: 'pnpm' - - - run: pnpm install - - - name: Run unit tests - run: pnpm run test - - - name: Set up webpack 5 tests - run: npx json -f package.json -I -e "this.resolutions = {}, this.resolutions.webpack = '^5.0.0', this.devDependencies.webpack = '^5.0.0' " - - - name: Install webpack 5 - run: pnpm install --no-frozen-lockfile - - - name: Run unit tests for webpack 5 - run: pnpm run test && pnpm run test:match-resource diff --git a/.gitignore b/.gitignore index 914a2dab2..e45d3c71e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ -.idea -.DS_Store -exploration node_modules -*.log -example/dist -docs/.vuepress/dist -test/.cache -.vscode -TODOS +npm-debug.log +test/output +docs/_book +.DS_Store +.idea +*.iml diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 6e52da593..000000000 --- a/.npmignore +++ /dev/null @@ -1,10 +0,0 @@ -example -test -*.yml -*.log -yarn.lock -tsconfig.json -docs -.github -.vscode -TODOS diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 4b1b4d60d..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,762 +0,0 @@ - -# [15.11.1](https://github.com/vuejs/vue-loader/compare/v15.11.0...v15.11.1) (2023-10-18) - -### Bug Fixes - -* fix: fix read property error for accessing lang of script ([#2060](https://github.com/vuejs/vue-loader/pull/2060)) - - - -# [15.11.0](https://github.com/vuejs/vue-loader/compare/v15.10.2...v15.11.0) (2023-10-18) - -### Features - -* A new `experimentalInlineMatchResource` option (webpack 5 only), which leverages webpack 5's [inline matchResource](https://webpack.js.org/api/loaders/#inline-matchresource) feature in the underlying implementation, and works well with the [`experiments.css`](https://webpack.js.org/configuration/experiments/#experimentscss) feature. This also makes `vue-loader` compatible with [Rspack](https://www.rspack.dev/guide/vue). ([#2058](https://github.com/vuejs/vue-loader/pull/2058)) - - - -# [15.10.2](https://github.com/vuejs/vue-loader/compare/v15.10.1...v15.10.2) (2023-08-23) - -### Bug Fixes - -* don't enable prettify by default if prettier 3 is detected ([aa2558d](https://github.com/vuejs/vue-loader/commit/aa2558d)) - - - -# [15.10.1](https://github.com/vuejs/vue-loader/compare/v15.10.0...v15.10.1) (2022-11-14) - -### Bug Fixes - -* skip thread-loader when cloning js rules to template compilation pipeline, fixes ([fb6ff6e](https://github.com/vuejs/vue-loader/commit/fb6ff6e)) - - - -# [15.10.0](https://github.com/vuejs/vue-loader/compare/v15.10.0-beta.6...v15.10.0) (2022-07-01) - - - - -# [15.10.0-beta.6](https://github.com/vuejs/vue-loader/compare/v15.10.0-beta.5...v15.10.0-beta.6) (2022-06-20) - - -### Bug Fixes - -* always pass id to stylePostLoader when possible ([364ad09](https://github.com/vuejs/vue-loader/commit/364ad09)) - - - - -# [15.10.0-beta.5](https://github.com/vuejs/vue-loader/compare/v15.10.0-beta.4...v15.10.0-beta.5) (2022-06-20) - - -### Bug Fixes - -* css v-bind in production mode ([655e5f8](https://github.com/vuejs/vue-loader/commit/655e5f8)) - - - - -# [15.10.0-beta.4](https://github.com/vuejs/vue-loader/compare/v15.10.0-beta.3...v15.10.0-beta.4) (2022-06-20) - - -### Features - -* support css v-bind (requires 2.7.0-beta.3) ([d653f3b](https://github.com/vuejs/vue-loader/commit/d653f3b)) - - - - -# [15.10.0-beta.3](https://github.com/vuejs/vue-loader/compare/v15.10.0-beta.2...v15.10.0-beta.3) (2022-06-16) - - -### Bug Fixes - -* cache descriptor with correct resource path ([f6c83b5](https://github.com/vuejs/vue-loader/commit/f6c83b5)) - - - - -# [15.10.0-beta.2](https://github.com/vuejs/vue-loader/compare/v15.10.0-beta.1...v15.10.0-beta.2) (2022-06-16) - - -### Features - -* use script-analyzed bindings when compiling template ([55de28c](https://github.com/vuejs/vue-loader/commit/55de28c)) - - - - -# [15.10.0-beta.1](https://github.com/vuejs/vue-loader/compare/v15.9.8...v15.10.0-beta.1) (2022-06-14) - - -### Features - -* apply js loaders to compiled template code when used with 2.7 ([30464a8](https://github.com/vuejs/vue-loader/commit/30464a8)) -* compat for vue 2.7, support ` - - +``` js +npm install -g vue-cli +vue init webpack-simple hello +cd hello +npm install +npm run dev ``` -There are many cool features provided by `vue-loader`: - -- Allows using other webpack loaders for each part of a Vue component, for example Sass for ` -``` - -There are many cool features provided by `vue-loader`: - -- Allows using other webpack loaders for each part of a Vue component, for example Sass for ` +``` + +Under the hood, the text content inside the ` +``` + +However, note this makes your Vue component Webpack-specific and not compatible with Browserify and [vueify](https://github.com/vuejs/vueify). **If you intend to ship your Vue component as a reusable 3rd-party component, avoid using this syntax.** diff --git a/docs/en/features/css-modules.md b/docs/en/features/css-modules.md new file mode 100644 index 000000000..2e825c371 --- /dev/null +++ b/docs/en/features/css-modules.md @@ -0,0 +1,118 @@ +# CSS Modules + +> requires ^9.8.0 + +[CSS Modules](https://github.com/css-modules/css-modules) is a popular system for modularizing and composing CSS. `vue-loader` provides first-class integration with CSS Modules as an alternative for simulated scoped CSS. + +### Usage + +Just add the `module` attribute to your ` +``` + +This will turn on CSS Modules mode for `css-loader`, and the resulting class identifier object will be injected into the component as a computed property with the name `$style`. You can use it in your templates with a dynamic class binding: + +``` html + +``` + +Since it's a computed property, it also works with the object/array syntax of `:class`: + +``` html + +``` + +And you can also access it from JavaScript: + +``` html + +``` + +Refer to the [CSS Modules spec](https://github.com/css-modules/css-modules) for mode details such as [global exceptions](https://github.com/css-modules/css-modules#exceptions) and [composition](https://github.com/css-modules/css-modules#composition). + +### Custom Inject Name + +You can have more than one ` + + +``` + +### Configuring `css-loader` Query + +CSS Modules are processed via [css-loader](ttps://github.com/webpack/css-loader). With ` + + +``` + +Into the following: + +``` html + + + +``` + +#### Notes + +1. You can include both scoped and non-scoped styles in the same component: + + ``` html + + + + ``` + +2. A child component's root node will be affected by both the parent's scoped CSS and the child's scoped CSS. + +3. Partials are not affected by scoped styles. + +4. **Scoped styles do not eliminate the need for classes**. Due to the way browsers render various CSS selectors, `p { color: red }` will be many times slower when scoped (i.e. when combined with an attribute selector). If you use classes or ids instead, such as in `.example { color: red }`, then you virtually eliminate that performance hit. [Here's a playground](http://stevesouders.com/efws/css-selectors/csscreate.php) where you can test the differences yourself. + +5. **Be careful with descendant selectors in recursive components!** For a CSS rule with the selector `.a .b`, if the element that matches `.a` contains a recursive child component, then all `.b` in that child component will be matched by the rule. diff --git a/docs/en/options.md b/docs/en/options.md new file mode 100644 index 000000000..6789e7c71 --- /dev/null +++ b/docs/en/options.md @@ -0,0 +1,157 @@ +# Options Reference + +## Usage Difference Between Webpack 1 & 2 + +For Webpack 1.x: add a root `vue` block in your Webpack config: + +``` js +module.exports = { + // ... + vue: { + // vue-loader options + } +} +``` + +For Webpack 2 (^2.1.0-beta.25): + +``` js +module.exports = { + // ... + module: { + rules: [ + { + test: /\.vue$/, + loader: 'vue', + options: { + // vue-loader options + } + } + ] + } +} +``` + +### loaders + +- type: `Object` + + An object specifying Webpack loaders to use for language blocks inside `*.vue` files. The key corresponds to the `lang` attribute for language blocks, if specified. The default `lang` for each type is: + + - `